diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index f0f5a2409..61cc5d331 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -4883,6 +4883,12 @@ static void valueFlowForwardAssign(Token* const tok, if (vars.size() == 1 && vars.front()->isStatic() && init) lowerToPossible(values); + // is volatile + if (std::any_of(vars.begin(), vars.end(), [&](const Variable* var) { + return var->isVolatile(); + })) + lowerToPossible(values); + // Skip RHS const Token * nextExpression = tok->astParent() ? nextAfterAstRightmostLeaf(tok->astParent()) : tok->next(); diff --git a/test/testcondition.cpp b/test/testcondition.cpp index e695a62f2..6ae692f96 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -3838,6 +3838,18 @@ private: " if (b) {}\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // #10223 + check("static volatile sig_atomic_t is_running;\n" + "static void handler(int signum) {\n" + " is_running = 0;\n" + "}\n" + "void f() {\n" + " signal(SIGINT, &handler);\n" + " is_running = 1;\n" + " while (is_running) {}\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void alwaysTrueSymbolic()