Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A switch statement consists of several case labels, plus a default label. The default label is optional but recommended. (See MSC01-C. Strive for logical completeness.) A series of statements following a case label conventionally ends with a break statement; if omitted, control flow falls through to the next case in the switch statement block. Because the break statement is not required, omitting it does not produce compiler diagnostics. If the omission was unintentional, it can result in an unexpected control flow.

...

Tool

Version

Checker

Description

Compass/ROSE

 

 

 

Coverity Prevent

Include Page
Coverity_V
Coverity_V

MISSING_BREAK

Can find instances of missing break statement between cases in switch statement.

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

swchsynt

Fully implemented.

...

The CERT Oracle Secure Coding Standard for Java: MSC55MSC53-JJG. Finish every set of statements associated with a case label with a break statement

...