Scope of Rule #11.2 - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21) +---- Forum: 8.11 Pointer type conversions (https://forum.misra.org.uk/forumdisplay.php?fid=166) +---- Thread: Scope of Rule #11.2 (/showthread.php?tid=955) |
Scope of Rule #11.2 - gs - 09-04-2013 Does rule 11.2 apply to just casts or to implicit conversions as well? Re: Scope of Rule #11.2 - Steve Montgomery - 04-09-2013 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 6.5.16.1 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: Code: struct incomplete *p; Re: Scope of Rule #11.2 - misra-c - 12-09-2013 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 |