MISRA C:2012 Rule 13.3
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
Description
Rule Definition
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.
Rationale
The rule is violated if the following happens in the same line of code:
The increment or decrement operator acts on a variable.
Another read or write operation is performed on the variable.
For example, the line y=x++
violates
this rule. The ++
and =
operator
both act on x
.
Although the operator precedence rules determine the order of
evaluation, placing the ++
and another operator
in the same line can reduce the readability of the code.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Side Effects |
Category: Advisory |
AGC Category: Readability |