Main Content
MISRA C:2012 Rule 13.1
Initializer lists shall not contain persistent side effects
Description
Rule Definition
Initializer lists shall not contain persistent side effects.
Rationale
C99 permits initializer lists with expressions that can be evaluated only at run-time. However, the order in which elements of the list are evaluated is not defined. If one element of the list modifies the value of a variable which is used in another element, the ambiguity in order of evaluation causes undefined values. Therefore, this rule requires that expressions occurring in an initializer list cannot modify the variables used in them.
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 R2014b