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

SR:  9.4.2#5Checked automatically with code checker

Synopsis:The switch expression shall not contain the ">", ">=", "<", "<=", "==", "!=", "&&", "||" or "!" operators.
Language:C
Severity Level:5
Category:STATEMENTS


Description:
Using relational or logical conjunctive operators in a switch expression is very likely to be wrong and is at best confusing.

Example:

switch( a > b ) /* WRONG */
{
    case ´b´:
    case ´c´:
      j = 4;
      break;
}

Example:

switch( a ) /* RIGHT */
{
    case ´b´:
    case ´c´:
      j = 4;
      break;
}