From 1193f6661318b2a57b150b38bd812a268947227a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:02:35 +0200 Subject: [PATCH 1/2] Update astutils.cpp --- lib/astutils.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 8e6ee974f15..b2656f4d31b 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -775,10 +775,11 @@ std::vector getParentValueTypes(const Token* tok, const Settings& set if (scope && scope->numConstructors == 0 && t->derivedFrom.empty() && (t->isClassType() || t->isStructType()) && numberOfArguments(ftok) <= scope->varlist.size() && !scope->varlist.empty()) { - assert(argn < scope->varlist.size()); - auto it = std::next(scope->varlist.cbegin(), argn); - if (it->valueType()) - return {*it->valueType()}; + if (argn < scope->varlist.size()) { + auto it = std::next(scope->varlist.cbegin(), argn); + if (it->valueType()) + return { *it->valueType() }; + } } } } From 5d7ee581b1aa3e5194d36cfe6626a3b2479c4341 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 20 Aug 2025 13:03:46 +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 c0fc9867df2..fe0ea225b5b 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -7980,6 +7980,18 @@ class TestValueFlow : public TestFixture { " return (!std::is_reference::value);\n" "}\n"; (void)valueOfTok(code, "0"); + + code = "struct S { int a; };\n" // #14036 + "template \n" + "struct U {\n" + " U() = default;\n" + " U(int i, int* p) {\n" + " m = new T(i, p);\n" + " }\n" + " T m;\n" + "};\n" + "U u;\n"; + (void)valueOfTok(code, "new"); } void valueFlowHang() {