MISRA Discussion Forums

Full Version: Rule 10.2 Are increment/decrement compliant
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Are the increment and decrement operators on essentially character type allowed?
Code:
char c = ‘A’;
   c++;  /* compliant or not compliant */
  • 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.