MISRA C++:2008 Rule 6-6-4
For any iteration statement there shall be no more than one break or goto statement used for loop termination
描述
规则定义
For any iteration statement there shall be no more than one break or goto statement used for loop termination. 1
理由
在迭代语句中使用多个 break
或 goto
语句会增加代码的复杂度。为了实现良好的结构化编程,请使用单个的 break
或 goto
语句。
Polyspace 实现
当单个循环中同时存在多个 break
语句、goto
语句或这些语句的组合时,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.