CWARN.CONSTCOND.IF

Condition of if expression is constant

The CWARN.CONSTCOND.IF checker finds instances in which the condition of a if 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(int x) {
    if (x=10) {} 
  }

Klocwork flags line 2, which contains a condition that will never change.