Two comparisons of the same value with constants make a condition that is always false or always true

tx0/cpp:impossible-conditionrecommendedwarningreliability/control-flowdepth fastbug, cwe-570

What it finds

x < 0 && x > 10 is never true and x > 5 || x < 10 always is: the two ranges do not overlap, or together cover every value. Usually one comparison is the wrong way round or && and || are swapped.

Both operands of the && or || must compare the same expression, without calls or side effects, with integer constants written with literals.

From the rule's source, impossible_condition.rs.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/cpp:impossible-condition" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/cpp:impossible-condition] reason="..."

tx0 explain tx0/cpp:impossible-condition shows the same in the terminal. Found a false positive? Report it.