MISRAC2004-13.7_b
In this section:
Synopsis
(Required) Boolean operations whose results are invariant shall not be permitted.
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
A comparison using ==, <, <=, >, or >= was found that always evaluates to false. This check is identical to RED-cmp-never.
Coding standards
- CWE 570
Expression is Always False
- MISRA C:2004 13.7
(Required) Boolean operations whose results are invariant shall not be permitted.
Code examples
The following code example fails the check and will give a warning:
int example(void) {
int x = 10;
if (x < 10) { //never true
return 1;
}
return 0;
}
The following code example passes the check and will not give a warning about this issue:
int example(int x) {
if (x < 10) { //OK - may be true
return 1;
}
return 0;
}