Why is this an issue?
If a label is declared but not used in the program, it can be considered as dead code and should therefore be removed.
This will improve maintainability as developers will not wonder what this label is used for.
Noncompliant code example
void fun() {
label: doSomething();
}
Compliant solution
void fun() {
doSomething();
}
Resources
- MISRA C:2012, 2.6 - A function should not contain unused label declarations
- CERT, MSC12-C. - Detect and remove code that has no effect or is never executed