MISRA C:2012 Rule 15.2
The goto statement shall jump to a label declared later in the same function
Description
Note
Using Code Prover for checking coding rules is no longer supported. See Version History.
Rule Definition
The goto statement shall jump to a label declared later in the same function.
Rationale
Unrestricted use of goto
statements makes
the program unstructured and difficult to understand. You can use
a forward goto
statement together with a backward
one to implement iterations. Restricting backward goto
statements
ensures that you use only iteration statements provided by the language
such as for
or while
to implement
iterations. This restriction reduces visual complexity of the code.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Control Flow |
Category: Required |
AGC Category: Advisory |