Rule 10.2 Are increment/decrement compliant

Moderators: misra-c, david ward

Post Reply
misra-c
Posts: 566
Joined: Thu Jan 05, 2006 1:11 pm

Rule 10.2 Are increment/decrement compliant

Post by misra-c » Fri Feb 13, 2015 10:01 am

Are the increment and decrement operators on essentially character type allowed?

Code: Select all

   char c = ‘A’;
   c++;  /* compliant or not compliant */
---
Posted by and on behalf of
the MISRA C Working Group

misra-c
Posts: 566
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 10.2 Are increment/decrement compliant

Post by misra-c » Fri Feb 13, 2015 10:03 am

  • Rule 10.2 only applies to the binary +, -, += and -= operators.
  • Rule 10.1 permits plain char as an operand to increment/decrement operators, as explained in the sentence "Under this rule the ++ and -- operators behave the same way as the binary + and - operators.
  • Rule 10.4 does not apply to the increment/decrement operator, as explained in the sentence “the increment and decrement operators are not covered by this rule.”
In summary, when taking all the essential type rules together, increment/decrement on essentially character is allowed.
---
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.10 The essential type model”