diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 7863d98cd..1a1d0bbd1 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -733,7 +733,7 @@ static void valueFlowOppositeCondition(SymbolDatabase *symboldatabase, const Set const Token *cond2 = tok2->tokAt(4)->astOperand2(); if (!cond2 || !cond2->isComparisonOp()) continue; - if (isOppositeCond(false, cpp, cond1, cond2, settings->library.functionpure)) { + if (isOppositeCond(true, cpp, cond1, cond2, settings->library.functionpure)) { ValueFlow::Value value(1); value.setKnown(); setTokenValue(const_cast(cond2), value); diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 8d366a8c8..b73e0fa8a 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1897,6 +1897,12 @@ private: ASSERT_EQUALS(1, value.intvalue); ASSERT(value.isKnown()); + code = "int f(int x) {\n" + " if (x < 2) {}\n" + " else if (x > 2) {}\n" // <- possible value + "}"; + ASSERT(isNotKnownValues(code, ">")); + // function code = "int f(int x) { return x + 1; }\n" // <- possible value "void a() { f(12); }\b";