CWARN.CONSTCOND.SWITCH
Switch selector expression is constant
The CWARN.CONSTCOND.SWITCH checker finds instances in which the condition of a switch statement is constant.
Vulnerability and risk
A constant condition for a statement typically results in the program's intention not being accomplished, with probable unexpected consequences.
Vulnerable code example
Copy
void foo() {
switch(3 + 2) { }
}
Klocwork flags line 2, in which the switch selector is a constant.