diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index ef81fc772ac..89dff71bc5e 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3606,6 +3606,8 @@ static void valueFlowSymbolic(const TokenList& tokenlist, const SymbolDatabase& continue; if (tok->astOperand2()->exprId() == 0) continue; + if (tok->astOperand2()->variable() && tok->astOperand2()->variable()->isArray() && tok->astOperand2()->variable()->getTypeName() != "std::array") // array to pointer decay + continue; if (!isConstExpression(tok->astOperand2(), settings.library)) continue; if (tok->astOperand1()->valueType() && tok->astOperand2()->valueType()) { diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 888710ce57d..886d1058190 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -9092,6 +9092,15 @@ class TestValueFlow : public TestFixture { " return x;\n" "}\n"; ASSERT_EQUALS(false, testValueOfX(code, 3U, "malloc(10)", 0)); + + code = "struct S {\n" // #14891 + " void f() const {\n" + " const int* p = a;\n" + " if (*p) {}\n" + " }\n" + " int a[3];\n" + "};\n"; + ASSERT(tokenValues(code, "* p )").empty()); } void valueFlowSymbolicIdentity()