Main Content
MISRA C:2023 Rule 15.2
The goto statement shall jump to a label declared later in the same function
Since R2024a
Description
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 |
Version History
Introduced in R2024a