Predicate reachablePointlessComparison
Holds if cmp
is a pointless comparison (see pointlessComparison
above) and cmp
occurs in reachable code. The reason for excluding
expressions that occur in unreachable code is that range analysis
sometimes can deduce impossible ranges for them. For example:
if (10 < x) { if (x < 5) { // Unreachable code return x; // x has an empty range: 10 < x && x < 5 } }
Import path
import semmle.code.cpp.rangeanalysis.PointlessComparison
predicate reachablePointlessComparison(ComparisonOperation cmp, float left, float right, boolean value, SmallSide ss)