From 9549ab630bf6fcba5ce77f83af98b4abfdb679fa Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 7 Jul 2026 16:07:21 +0200 Subject: [PATCH 1/5] Update vf_analyzers.cpp --- lib/vf_analyzers.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index cfba7d5f970..6ebd5adf9f7 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -616,6 +616,8 @@ struct ValueFlowAnalyzer : Analyzer { return Action::None; Action la = analyzeLifetime(lifeTok); if (la.matches()) { + if (tok->isUnaryOp("*") && tok->valueType() && lifeTok->valueType() && tok->valueType()->pointer < lifeTok->valueType()->pointer) + return Action::Invalid; Action a = Action::Read; if (isModified(tok).isModified()) a = Action::Invalid; From 232bbf4a8055581341b2cf6e3fb417759f37fb15 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 7 Jul 2026 16:08:47 +0200 Subject: [PATCH 2/5] Update testvalueflow.cpp --- test/testvalueflow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) 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() From 926fe38a3779e7a451ee62fb682a9a327167b19a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 13 Jul 2026 08:46:56 +0200 Subject: [PATCH 3/5] Update vf_analyzers.cpp [skip ci] --- lib/vf_analyzers.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/vf_analyzers.cpp b/lib/vf_analyzers.cpp index 6ebd5adf9f7..cfba7d5f970 100644 --- a/lib/vf_analyzers.cpp +++ b/lib/vf_analyzers.cpp @@ -616,8 +616,6 @@ struct ValueFlowAnalyzer : Analyzer { return Action::None; Action la = analyzeLifetime(lifeTok); if (la.matches()) { - if (tok->isUnaryOp("*") && tok->valueType() && lifeTok->valueType() && tok->valueType()->pointer < lifeTok->valueType()->pointer) - return Action::Invalid; Action a = Action::Read; if (isModified(tok).isModified()) a = Action::Invalid; From 076bafd79e83d27e848457edfd6b8ac15317e18b Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 13 Jul 2026 08:49:31 +0200 Subject: [PATCH 4/5] Update valueflow.cpp --- lib/valueflow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index ef81fc772ac..225ea143f27 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()) { From ccd2c287920b6430a5b3895de81d2557784d9d29 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 13 Jul 2026 09:13:43 +0200 Subject: [PATCH 5/5] Update valueflow.cpp --- lib/valueflow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 225ea143f27..89dff71bc5e 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -3606,7 +3606,7 @@ 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 + 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;