Versions Compared

Key

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

...

MSC17:EX2: When control flow is intended to cross statement labels, it is permissible to omit the break statement. In these instances, the unusual control flow must be explicitly documented.

Code Block
bgColor#FFCCCC#CCCCFF
enum WidgetEnum { WE_W, WE_X, WE_Y, WE_Z } widget_type;
widget_type = WE_X;

switch (widget_type) {
  case WE_W:
    /* ... */
    /* no break, process case for WE_X as well */
  case WE_X:
    /* ... */
    break;
  case WE_Y: case WE_Z:
    /* ... */
    break;
  default: /* can't happen */
	 /* handle error condition */
}

...

This rule appears in the C++ Secure Coding Standard as MSC17MSC18-CPP. Finish every set of statements associated with a case label with a break statement.

...