Synopsis: | The switch expression shall not contain any logical expression (one or more of the ">", ">=", "<", "<=", "==", "!=", "&&", "||" or "!" operators). |
Language: | C |
Severity Level: | 5 |
Category: | Statement and Blocks |
Description: |
Justification Using relational or logical operators in a "switch" expression is very likely to be wrong and is at best confusing. Consider the use of an "if" statement. Example #define CCBB_THE_CHOICE 1 switch (option == pick) /* WRONG */ { case CCBB_THE_CHOICE: /* any statement */ break; default: /* any statement */ break; } |