MISRA C++:2008 Rule 8-5-1
All variables shall have a defined value before they are used
描述
规则定义
All variables shall have a defined value before they are used. 1
理由
C++ 标准未指定未初始化的内存的值。该值无法预测,每次运行程序时可能会不同。读取和使用未初始化的内存值会导致意外行为。
Polyspace 实现
如果您的代码包含以下问题,则 Polyspace® 会报告违反此规则:
Polyspace 不会检查类构造函数是否初始化了该类的非静态成员。
故障排除
如果您预期会出现违规,而 Polyspace 未报告该违规,请参阅诊断为何编码规范违规未按预期显示。
示例
检查信息
组:声明符 |
类别:必需 |
版本历史记录
在 R2013b 中推出1 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.