MISRA.CAST.VOID_PTR_TO_INT.2012Cast between a pointer to void and an arithmetic type.
MISRA C 2012 Rule 11.6: A cast shall not be performed between pointer to void and an arithmetic typeC90 [Undefined 29; Implementation 24], C99 [Undefined 21, 41; Implementation J.3.7(1)] Category: Required Analysis: Decidable, Single Translation Unit Applies to: C90, C99 RationaleConversion of an integer into a pointer to void may result in a pointer that is not correctly aligned, resulting in undefined behaviour. Conversion of a pointer to void into an integer may produce a value that cannot be represented in the chosen integer type resulting in undefined behaviour. Conversion between any non-integer arithmetic type and pointer to void is undefined. ExceptionAn integer constant expression with value 0 may be cast into pointer to void. Examplevoid * p; uint32_t u; /* Non-compliant - implementation-defined */ p = ( void * ) 0x1234u; /* Non-compliant - undefined */ p = ( void * ) 1024.0f; /* Non-compliant - implementation-defined */ u = ( uint32_t ) p; |