MISRA C:2012 Rule 9.1
The value of an object with automatic storage duration shall not be read before it has been set
Description
Message in Report:
Note
Using Code Prover for checking coding rules is no longer supported. See Version History.
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:
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 |