Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
11.3: How many 'levels' deep?
#5
(1) The Amplification states
Quote:"This rule applies to the unqualified types that are pointed to by pointers".

As explained in the previous answer to this question, only the qualifications at the top level of the type are ignored and therefore any lower qualifiers must be considered.
Consider a variation of the example in the document:
Code:
volatile int * const * pcpvi;     // pcpvi is a "pointer" to a const qualified object of type "pointer to volatile int".

The qualified type pointed to by pcpvi is "const pointer to volatile int"
The unqualified type pointed to by pcpvi is "pointer to volatile int"

Rule 11.3 is only concerned with the unqualified type pointed to by the pointer.
Rule 11.8 is only concerned with the removal of the top-level qualifier.

(volatile int * *) pcpvi would violate rule 11.8 since const removed.

(2) The p and q example in the document shows an example of different top level cv.
Code:
const short *p;               // cv is const
       const volatile short *q;      // cv is const volatile
       // The unqualified object type pointed to by both p and q is "short".
      
       q = ( const volatile short * ) p;  // compliant since both types point to the unqualified type of short.
Posted by and on behalf of the MISRA C Working Group


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)