Scope of Rule #11.2

Moderators: misra-c, david ward

Post Reply
Posts: 87
Joined: Thu Nov 18, 2004 1:39 am

Scope of Rule #11.2

Post by gs » Tue Apr 09, 2013 3:45 pm

Does rule 11.2 apply to just casts or to implicit conversions as well?

Steve Montgomery
Posts: 104
Joined: Fri Sep 17, 2004 1:31 pm
Company: .
Location: Northumberland or Isle of Skye

Re: Scope of Rule #11.2

Post by Steve Montgomery » Wed Sep 04, 2013 1:09 pm

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:

Code: Select all

struct incomplete *p;
_Bool b = p;

Posts: 571
Joined: Thu Jan 05, 2006 1:11 pm

Re: Scope of Rule #11.2

Post by misra-c » Thu Sep 12, 2013 10:28 am

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
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.11 Pointer type conversions”