MISRA C:2023 Rule 13.6
The operand of the sizeof operator shall not contain any expression which has potential side effects
Since R2024a
Description
Rule Definition
The operand of the sizeof operator shall not contain any expression which has potential side effects.
Rationale
The argument of a sizeof
operator is usually
not evaluated at run time. If the argument is an expression, you might
wrongly expect that the expression is evaluated.
Polyspace Implementation
The rule checker reports a violation if the operand of a sizeof
operator has side effects that persist beyond the sizeof
expression. For
instance, if the sizeof
operator increments a global variable, the rule
checker reports a violation.
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: Required |
AGC Category: Required |
Version History
Introduced in R2024a