Posts: 632
Threads: 18
Joined: Jan 2006
Reputation:
1
Are the increment and decrement operators on essentially character type allowed?
Code:
char c = ‘A’;
c++; /* compliant or not compliant */
Posted by and on behalf of the MISRA C Working Group
Posts: 632
Threads: 18
Joined: Jan 2006
Reputation:
1
- 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