Skip to content

Commit 1f1a07f

Browse files
Fix #11437 FP knownConditionTrueFalse when comparing clamped value (#8751)
1 parent cb694dd commit 1f1a07f

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

lib/valueflow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4276,6 +4276,7 @@ static void valueFlowAfterAssign(const TokenList &tokenlist,
42764276
continue;
42774277
const Token* expr = value.tokvalue;
42784278
value.intvalue = -value.intvalue;
4279+
value.invertBound();
42794280
value.tokvalue = tok->astOperand1();
42804281

42814282
// Skip if it intersects with an already assigned symbol

test/testcondition.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5244,6 +5244,12 @@ class TestCondition : public TestFixture {
52445244
" if (c) {}\n"
52455245
"}\n");
52465246
ASSERT_EQUALS("", errout_str());
5247+
5248+
check("void f(int a, int b) {\n" // #11437
5249+
" a = a < b ? b : a;\n"
5250+
" if (a != b) {}\n"
5251+
"}\n");
5252+
ASSERT_EQUALS("", errout_str());
52475253
}
52485254

52495255
void alwaysTrueInfer() {

0 commit comments

Comments
 (0)