Main Content
AUTOSAR C++14 Rule M6-6-2
The goto statement shall jump to a label declared later in the same function body
Description
Rule Definition
The goto statement shall jump to a label declared later in the same function body.
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, Automated |
Version History
Introduced in R2019a