From a511b3352fb1fc3d1b7ddeb056d8ae40f3a9b1b9 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 11 Mar 2026 10:57:46 +0100 Subject: [PATCH 1/2] Update vf_common.cpp --- lib/vf_common.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/vf_common.cpp b/lib/vf_common.cpp index 78f44de6754..32670fc0722 100644 --- a/lib/vf_common.cpp +++ b/lib/vf_common.cpp @@ -230,9 +230,7 @@ namespace ValueFlow setTokenValue(tok->tokAt(4), std::move(value), settings); } } else if (Token::Match(tok2, "%var% )")) { - const Variable *var = tok2->variable(); - // only look for single token types (no pointers or references yet) - if (var && var->typeStartToken() == var->typeEndToken()) { + if (const Variable *var = tok2->variable()) { // find the size of the type size_t size = 0; if (var->isEnumType()) { From c08008b576245df4391ee19aa95bc35c5ad238e3 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 11 Mar 2026 10:58:47 +0100 Subject: [PATCH 2/2] Update testvalueflow.cpp --- test/testvalueflow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 00ebe7f694f..f398c081d7f 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1742,6 +1742,15 @@ class TestValueFlow : public TestFixture { values = tokenValues(code, "( D )"); ASSERT_EQUALS(1U, values.size()); TODO_ASSERT_EQUALS(2 * settings.platform.sizeof_pointer, 1, values.back().intvalue); + + code = "int f() {\n" // #11335 + " int* a[2];" + " return sizeof(a);\n" + "}"; + values = tokenValues(code, "( a"); + ASSERT_EQUALS(1U, values.size()); + ASSERT_EQUALS(16, values.back().intvalue); + ASSERT_EQUALS_ENUM(ValueFlow::Value::ValueKind::Known, values.back().valueKind); } void valueFlowComma()