An unconditional break statement shall terminate every switch-clause
An unconditional break statement shall terminate every switch-clause
A switch-clause is a case containing at least one statement. Two consecutive labels without an intervening statement is compliant with MISRA®.
If you fail to end your switch-clauses with a break statement, then control flow “falls” into the next statement. This next statement can be another switch-clause, or the end of the switch. This behavior is sometimes intentional, but more often it is an error. If you add additional cases later, an unterminated switch-clause can cause problems.
Polyspace® raises a warning for each noncompliant case clause.
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: Switch Statements |
| Category: Required |
| AGC Category: Advisory |