このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。
MISRA C++:2008 Rule 6-6-1
Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement
説明
ルール定義
Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement 1
根拠
goto
ステートメントを使用して、入れ子にされたブロックにジャンプすると複雑な制御フローになり、開発者の混乱を招いたり、予期しない結果が生じたりする可能性があります。予期しない結果を回避するには、goto
ステートメントが参照するラベルを同じブロック内または goto
ステートメントを含むブロック内に配置します。
Polyspace 実装
Polyspace® は、goto
の移動先が goto
ステートメントとは異なるブロック内にある場合にこの欠陥を報告します。goto
の移動先が goto
を含むブロック内にある場合、この欠陥は報告されません。
トラブルシューティング
ルール違反が想定されるものの、Polyspace から報告されない場合は、コーディング規約違反が想定どおりに表示されない理由の診断を参照してください。
例
チェック情報
グループ: Statements |
カテゴリ: 必要 |
バージョン履歴
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.