06-03-2009, 09:36 AM
In Section 6.11 of the MISRA-C:2004 document, after the specification of Rule 11.5, the following example is reported:
In my understanding, this is not really a violation of the required Rule 11.5; rather, it is a violation of the advisory Rule 11.4, since the pointed-to types
(namely, and )
are two different pointer (hence, object) types; in particular, they are unqualified types.
This is quite the same as saying that
is a violation of 11.4 rather than 11.5.
Is my interpretation correct?
Or is it the case that Rule 11.5 has to be interpreted recursively,
so that in the two examples above we would have violations for both 11.4 and 11.5?
Thanks,
Enea.
Code:
/* ... snip ... */
const uint16_t * * ppci; /* pointer to pointer to const */
uint16_t * * ppi;
/* ... snip ... */
ppi = (uint16_t * *)ppci; /* Not compliant */
(namely,
Code:
const uint16_t *
Code:
uint16_t *
are two different pointer (hence, object) types; in particular, they are unqualified types.
This is quite the same as saying that
Code:
struct S { const char* s; };
struct T { char* s; };
struct S* ps;
struct T* pt = (struct T*) ps;
Is my interpretation correct?
Or is it the case that Rule 11.5 has to be interpreted recursively,
so that in the two examples above we would have violations for both 11.4 and 11.5?
Thanks,
Enea.