diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 9b60a5003..c71e93ee6 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -1857,7 +1857,7 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings* sett std::vector values; for (const Token* tok2 : tokens) { if (tok2->hasKnownIntValue()) { - values.emplace_back(); + values.emplace_back(tok2->values().front()); } else { ValueFlow::Value symValue{}; symValue.valueType = ValueFlow::Value::ValueType::SYMBOLIC; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 4cb72fc55..bfe9713fc 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -4940,6 +4940,11 @@ private: " if (j >= 0) {}\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("void f(int i) {\n" // #12039 + " if ((128 + i < 255 ? 128 + i : 255) > 0) {}\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void alwaysTrueContainer() {