TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
C++ Coding Standard
Search

Rule:  CFL#002Checked automatically with code checker

Synopsis:All switch statements shall have a default label as the last case label
Language:C++
Severity Level:2
Category:Control Flow


Description:

Example:

switch (c)
{
case c0:	// fall-through
case c1:
    {
        x;
        break;
    }
case c2:
    {
        y;
        break;
    }
default:	// always 'default' at end, even if no statement follows
    {
        z;	// possibly an assertion that this should not be reached
        break;	// leave break: in case this becomes a non-default case
    }
}


Literature References:
Ellemtel Rule 48
ISC++ Rec. 4.5