MISRA.CAST.OBJ_PTR_TO_NON_INT.2012A cast between a pointer to object and a non-integer arithmetic type.
MISRA C 2012 Rule 11.7: A cast shall not be performed between pointer to object and a non-integer 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 AmplificationFor the purposes of this rule a non-integer arithmetic type means one of:
RationaleConversion of an essentially Boolean, essentially character or essentially enum type into a pointer to object may result in a pointer that is not correctly aligned, resulting in undefined behaviour. Conversion of a pointer to object into an essentially Boolean, essentially character or essentially enum type may produce a value that cannot be represented in the chosen integer type resulting in undefined behaviour. Conversion of a pointer to object into or from an essentially floating type results in undefined behaviour. Exampleint16_t * p; float32_t f; f = ( float32_t ) p; /* Non-compliant */ p = ( int16_t * ) f; /* Non-compliant */ |