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:
Rule Definition
The value of an object with automatic storage duration shall not be read before it has been set1 .
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 |
Version History
Introduced in R2014b1 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.