MISRAC2012-Rule-13.3
Synopsis
(Advisory) A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator
Enabled by default
No
Severity/Certainty
Low/Medium

Full description
The increment (++) and decrement (--) operators are being used mixed with other operators in an expression. This check is identical to MISRAC2004-12.13, MISRAC++2008-5-2-10.
Coding standards
- MISRA C:2004 12.13
(Advisory) The increment (++) and decrement (--) operators should not be mixed with other operators in an expression.
- MISRA C:2012 Rule-13.3
(Advisory) A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator
- MISRA C++ 2008 5-2-10
(Advisory) The increment (++) and decrement (--) operators should not be mixed with other operators in an expression.
Code examples
The following code example fails the check and will give a warning:
void example(char *src, char *dst) {
while ((*src++ = *dst++));
}
The following code example passes the check and will not give a warning about this issue:
void example(char *src, char *dst) {
while (*src) {
*dst = *src;
src++;
dst++;
}
}