From 903eccb336c15d367b40a91abeb6588585e919a4 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 6 Oct 2023 09:53:24 +0200 Subject: [PATCH] Fix #12039 FP knownConditionTrueFalse (#5513) --- lib/valueflow.cpp | 2 +- test/testcondition.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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() {