Skip to content

Commit c150317

Browse files
authored
Fix 11384: FP knownConditionTrueFalse when variable is modified in return statement (#4625)
* Fix 11384: FP knownConditionTrueFalse when variable is modified in return statement * Format
1 parent c779cef commit c150317

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/valueflow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6070,7 +6070,7 @@ struct ConditionHandler {
60706070
});
60716071
for (Token* start:nextExprs) {
60726072
Analyzer::Result r = forward(start, cond.vartok, values, tokenlist);
6073-
if (r.terminate != Analyzer::Terminate::None)
6073+
if (r.terminate != Analyzer::Terminate::None || r.action.isModified())
60746074
return;
60756075
}
60766076
}

test/testcondition.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4640,6 +4640,13 @@ class TestCondition : public TestFixture {
46404640
" if (i == j) {}\n"
46414641
"}\n");
46424642
ASSERT_EQUALS("", errout.str());
4643+
4644+
// #11384
4645+
check("bool f(const int* it, const int* end) {\n"
4646+
" return (it != end) && *it++ &&\n"
4647+
" (it != end) && *it;\n"
4648+
"}\n");
4649+
ASSERT_EQUALS("", errout.str());
46434650
}
46444651

46454652
void alwaysTrueInfer() {

0 commit comments

Comments
 (0)