MISRA C++:2023 Rule 9.6.3
The goto
statement shall jump to a label declared later in the
function body
Since R2024b
Description
Rule Definition
The goto
statement shall jump to a label declared later in the
function body. 1
Rationale
Using a goto
statement to jump to a label earlier in the same
function body creates an iteration. Avoid creating iterations by using
goto
statements. Use iteration statements defined by the core language
because they are easier to understand and maintain than goto
statements.
Polyspace Implementation
Polyspace® raises this defect when an iteration is formed by using
goto
statements.
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: Statements |
Category: Required |
Version History
Introduced in R2024b
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.