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 operator1 .
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 |
Version History
Introduced in R2014bSee Also
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.