Rule 18.4 using -- operator for pointers

Moderators: misra-c, david ward

Post Reply
Posts: 1
Joined: Tue May 13, 2014 4:57 pm
Company: Axivion

Rule 18.4 using -- operator for pointers

Post by simondl » Thu Jul 17, 2014 7:28 am


Rule 18.4 mentions +, -, += and -= operators and also ++ operator (both post and pre fix?). -- operator is not mentioned. How to deal with it?


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

Re: Rule 18.4 using -- operator for pointers

Post by misra-c » Mon Aug 11, 2014 8:33 am

Rule 18.4 prohibits the use of "+, -, +=, -=" operators on expressions with a pointer type. All other operators that are legal C do not violate this rule. This includes ++ and --, both prefix and postfix.

The rationale mentions the ++ operator as an example of a valid operator that is not restricted by this rule. It was not intended that the rationale should list all valid operators.

As a general point, it should be remembered that the rationale section is not normative. Only the guideline headline and amplification (where present) are intended to specify which operators the guideline applies to.
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.18 Pointers and arrays”