MISRA Discussion Forums
Rule 10.2 Are increment/decrement compliant - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.10 The essential type model (https://forum.misra.org.uk/forumdisplay.php?fid=165)
+---- Thread: Rule 10.2 Are increment/decrement compliant (/showthread.php?tid=1147)



Rule 10.2 Are increment/decrement compliant - misra-c - 13-02-2015

Are the increment and decrement operators on essentially character type allowed?
Code:
char c = ‘A’;
   c++;  /* compliant or not compliant */



Re: Rule 10.2 Are increment/decrement compliant - misra-c - 13-02-2015

  • 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.