8.3.a. The break for each case shall be indented to align with the associated case, rather than with the contents of the case code block.

8.3.b. All switch statements shall contain a default block.

8.3.c. Any case designed to fall through to the next shall be commented to clearly explain the absence of the corresponding break.


switch (err)
  case ERR_A:

  case ERR_B:
  // Also perform the steps for ERR_C.
  case ERR_C:


Reasoning: C’s switch statements are powerful constructs, but prone to errors such as omitted break statements and unhandled cases. By aligning the case labels with their break statements it is easier to spot a missing break.

Enforcement: These rules shall be enforced during code reviews.


I use enums for case labels and intentionally avoid a final default clause when my intent is to ensure that each enum value is covered. Multiple compilers and static analysis tools will flag a missing case, a feature generally disabled by the presence of a default - and I always prefer build-time error detection to runtime detection! For this reason, the JSF C++ coding std (freely available online) discourages the default clause for these cases. As an aside, I also prefer C++ to C even if only used as a more typesafe C.