diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index def5e1026..afb04ab52 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5384,7 +5384,6 @@ static void valueFlowInferCondition(TokenList* tokenlist, ValueFlow::Value value = result.front(); value.intvalue = 1; value.bound = ValueFlow::Value::Bound::Point; - value.setKnown(); setTokenValue(tok, value, settings); } else if (Token::Match(tok, "%comp%|-") && tok->astOperand1() && tok->astOperand2()) { std::vector result = diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 067d4252a..4f5c53ab6 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -4046,6 +4046,15 @@ private: " }\n" "}\n"); ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Condition 'u1!=u2' is always true\n", errout.str()); + + // #10544 + check("void f(int N) {\n" + " if (N > 0) {\n" + " while (N)\n" + " N = test();\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void alwaysTrueContainer() {