MISRA Discussion Forums

Full Version: Scope of Rule #11.2
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does rule 11.2 apply to just casts or to implicit conversions as well?
I think that this rule is intended to apply to any conversion, implicit or explicit. However, the rule doesn't apply to pointers to void (Amplification) and explicitly permits null pointer constants (Exception 2) to be converted. Given this, most implicit conversions that would break this rule are already prohibited by constraints which the standard defines in terms of the constraints on the assignment operator (C99 in particular)

I believe that the following is an example of an implicit conversion that is permitted, by C99 at least, but prohibited by this rule:

struct incomplete *p;
_Bool b = p;
Throughout the MISRA C guidelines (and also the Standard) conversion means both explicit and implicit conversions

Therefore, Rule 11.2 shall apply to both casts as well as implicit conversions