Skip to content

Commit f1f86db

Browse files
authored
Fix 10544: FP knownConditionTrueFalse with loop after check (danmar#3508)
1 parent 6b9ef1f commit f1f86db

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/valueflow.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5384,7 +5384,6 @@ static void valueFlowInferCondition(TokenList* tokenlist,
53845384
ValueFlow::Value value = result.front();
53855385
value.intvalue = 1;
53865386
value.bound = ValueFlow::Value::Bound::Point;
5387-
value.setKnown();
53885387
setTokenValue(tok, value, settings);
53895388
} else if (Token::Match(tok, "%comp%|-") && tok->astOperand1() && tok->astOperand2()) {
53905389
std::vector<ValueFlow::Value> result =

test/testcondition.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4046,6 +4046,15 @@ class TestCondition : public TestFixture {
40464046
" }\n"
40474047
"}\n");
40484048
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (style) Condition 'u1!=u2' is always true\n", errout.str());
4049+
4050+
// #10544
4051+
check("void f(int N) {\n"
4052+
" if (N > 0) {\n"
4053+
" while (N)\n"
4054+
" N = test();\n"
4055+
" }\n"
4056+
"}\n");
4057+
ASSERT_EQUALS("", errout.str());
40494058
}
40504059

40514060
void alwaysTrueContainer() {

0 commit comments

Comments
 (0)