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 guideline recommendation 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, this can result in an unexpected control flow.

...

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

Related Guidelines

CERT C++ Secure Coding Standard: MSC18-CPP. Finish every set of statements associated with a case label with a break statement

...