Synopsis: | The default clause should be the last entry in the switch statement. |
Language: | C |
Severity Level: | 4 |
Category: | STATEMENTS |
Description: |
Since the default action is a 'catch-all' it aids the reader to enumerate the possible special cases before the general case. Example:Example:switch( a ) { default: break; /* WRONG - default clause not last */ case 'c': j = 4; break; case 'd': break; } switch( a ) { case 'c': j = 4; break; case 'd': break; default: break; /* RIGHT - default clause last */ } |