-
Type:
Language-Specification
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Impact:Unknown 'null' severity
-
Likelihood:Unknown 'null' severity
-
Default Quality Profiles:Override none
-
Legacy Key:GotoUsage
Noncompliant Code Example
int i = 0; loop: printf("i = %d\n", i); i++; if (i < 10){ goto loop; // Noncompliant }
Compliant Solution
for (int i = 0; i < 10; i++) { printf("i = %d\n", i); }
See
- MISRA C:2004, 14.4 - The goto statement shall not be used.
- MISRA C:2012, 15.1 - The goto statement should not be used
- C++ Core Guidelines ES.76: Avoid goto