From 1fe3d950dc4f9657cbdde8469e37632aafb0a52c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 24 Jun 2026 15:26:08 +0200 Subject: [PATCH 1/2] Update valueflow.cpp --- lib/valueflow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index fb9f6dda7a1..967beaf3ea6 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -4099,6 +4099,8 @@ static bool isVariableInit(const Token *tok) return false; if (var->nameToken() != tok->astOperand1()) return false; + if (var->isPointer()) + return true; const ValueType* vt = var->valueType(); if (!vt) return false; From e71c3a8cc499d5a69c1a3b70e19e8016051ba6b9 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 24 Jun 2026 15:27:30 +0200 Subject: [PATCH 2/2] Update testvalueflow.cpp --- test/testvalueflow.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 8305a63bc56..7fa28855eb1 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -3188,6 +3188,18 @@ class TestValueFlow : public TestFixture { " return x;\n" "}\n"; ASSERT_EQUALS(true, testValueOfXKnown(code, 3U, -1)); + + code = "A* f() {\n" // #14864 + " A* x{};\n" + " return x;\n" + "}\n"; + ASSERT_EQUALS(true, testValueOfXKnown(code, 3U, 0)); + + code = "A* f() {\n" + " A* x{ nullptr };\n" + " return x;\n" + "}\n"; + ASSERT_EQUALS(true, testValueOfXKnown(code, 3U, 0)); } void valueFlowAfterSwap()