diff --git a/lib/forwardanalyzer.cpp b/lib/forwardanalyzer.cpp index 46575479d..d9c7ebb29 100644 --- a/lib/forwardanalyzer.cpp +++ b/lib/forwardanalyzer.cpp @@ -417,7 +417,8 @@ struct ForwardTraversal { actions |= allAnalysis; // do while(false) is not really a loop if (checkElse && isDoWhile && - (condTok->hasKnownIntValue() || (!bodyAnalysis.isModified() && condAnalysis.isRead()))) { + (condTok->hasKnownIntValue() || + (!bodyAnalysis.isModified() && !condAnalysis.isModified() && condAnalysis.isRead()))) { if (updateRange(endBlock->link(), endBlock) == Progress::Break) return Break(); return updateRecursive(condTok); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 4f5c53ab6..f50848b53 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -3793,6 +3793,13 @@ private: " }\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // #10548 + check("void f() {\n" + " int i = 0;\n" + " do {} while (i++ == 0);\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void alwaysTrueSymbolic()