diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 4c3b8c058..b0e9aad57 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -2428,7 +2428,7 @@ struct ExpressionAnalyzer : SingleValueFlowAnalyzer { return; visitAstNodes(start, [&](const Token* tok) { for (const ValueFlow::Value& v : tok->values()) { - if (!v.isLocalLifetimeValue()) + if (!(v.isLocalLifetimeValue() || (astIsPointer(tok) && v.isSymbolicValue() && v.isKnown()))) continue; if (!v.tokvalue) continue; diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 7bbfbfbd9..4c93dbe2c 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -3642,6 +3642,27 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); + // #10121 + check("struct AB {\n" + " int a;\n" + "};\n" + "struct ABC {\n" + " AB* ab;\n" + "};\n" + "void g(ABC*);\n" + "int f(struct ABC *abc) {\n" + " int err = 0;\n" + " AB *ab = abc->ab;\n" + " if (ab->a == 123){\n" + " g(abc);\n" + " if (ab->a != 123) {\n" + " err = 1;\n" + " }\n" + " }\n" + " return err;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + // #10323 check("void foo(int x) {\n" " if(x)\n"