13-12-2013, 09:03 AM
This rule only applies to object pointers, as other types of pointers are covered by other rules.
We will consider clarifying the amplification to read:
An object pointer should not be converted into an integer.
An integer should not be converted into an object pointer.
We will consider clarifying the amplification to read:
An object pointer should not be converted into an integer.
An integer should not be converted into an object pointer.
Code:
void *vp = 1; /* Constraint error in C90 and C99; violates rule 1.1 */
int (*fp)(void) = 1; /* Constraint error in C90 and C99; violates rule 1.1 */
/* The following will all violate 11.9 */
int *ip = 0; /* compliant with 11.4 exception */
void *vp = 0; /* compliant with all other section 11 rules */
int (*fp)(void) = 0; /* 11.4 does not apply, compliant with 11.1 exception */
Posted by and on behalf of the MISRA C Working Group