MISRA C++:2008 Rule 8-5-1
All variables shall have a defined value before they are used
Description
Rule Definition
All variables shall have a defined value before they are used.1
Rationale
The C++ standard does not specify what the value of an uninitialized memory is. This value is unpredictable and can be different every time the program runs. Reading and using the value of an uninitialized memory results in unexpected behavior.
Polyspace Implementation
Polyspace® reports a violation of this rule if your code contains these issues:
Polyspace does not check if the constructor of a class initializes the nonstatic members of the class.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Declarators |
Category: Required |
Version History
Introduced in R2013b1 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.