Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 18.4 using -- operator for pointers
#1
Dear

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

Regards
<t></t>
#2
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


Forum Jump:


Users browsing this thread: 1 Guest(s)