Skip to content

Commit

Permalink
Fix #13522 FP knownConditionTrueFalse after unsigned-to-signed conver…
Browse files Browse the repository at this point in the history
…sion (#7179)
  • Loading branch information
chrchr-github authored Feb 23, 2025
1 parent 9288b8e commit 80047b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/vf_analyzers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ struct ValueFlowAnalyzer : Analyzer {
continue;
if (exact && v.intvalue != 0 && !isPoint)
continue;
if (astIsUnsigned(tok) != astIsUnsigned(v.tokvalue))
continue;
std::vector<MathLib::bigint> r;
ValueFlow::Value::Bound bound = currValue->bound;
if (match(v.tokvalue)) {
Expand Down
7 changes: 7 additions & 0 deletions test/testcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4968,6 +4968,13 @@ class TestCondition : public TestFixture {
" }\n"
"}\n");
ASSERT_EQUALS("", errout_str());

check("void f(unsigned x) {\n" // #13522
" unsigned u = x;\n"
" int i = u - 0;\n"
" if (i < 0) {}\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

void alwaysTrueInfer() {
Expand Down

0 comments on commit 80047b5

Please sign in to comment.