MISRA C:2023 Rule 9.1
The value of an object with automatic storage duration shall not be read before it has been set
Since R2024a
Description
Message in Report:
Rule Definition
The value of an object with automatic storage duration shall not be read before it has been set.
Rationale
A variable with an automatic storage duration is allocated memory
at the beginning of an enclosing code block and deallocated at the
end. All non-global variables have this storage duration, except those
declared static
or extern
.
Variables with automatic storage duration are not automatically initialized and have indeterminate values. Therefore, you must not read such a variable before you have set its value through a write operation.
Polyspace Implementation
Polyspace® reports a violation of this rule if your code contains these issues:
Polyspace reports a violation of this issue on _Atomic
qualified
variables that are uninitialized. You can justify these violations using code annotations.
See Annotate Code and Hide Known or Acceptable Results. Alternatively, you
can justify these violation using the Polyspace user interface. See Address Results in Polyspace User Interface Through Bug Fixes or Justifications.
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: Initialization |
Category: Mandatory |
AGC Category: Mandatory |
Version History
Introduced in R2024a