From a426d91df9c217b2ccc5faba2ef043a394f6f5fb Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 7 Sep 2026 16:15:14 +0200 Subject: [PATCH 1/2] Update astutils.cpp --- lib/astutils.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 1faafd4ba09..4ebbc8644da 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1159,6 +1159,8 @@ bool exprDependsOnThis(const Token* expr, bool onVar, nonneg int depth) } if (expr->isOperatorKeyword() && !Token::simpleMatch(expr->next()->astParent(), ".")) return true; + if (expr->variable() && expr->variable()->isArgument() && !expr->variable()->type() && expr->variable()->scope()->function && expr->variable()->scope()->function->templateDef) + return true; } if (onVar && expr->variable()) { const Variable* var = expr->variable(); From 2de1880180dcb06283f7e298a8e54e1960262112 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 7 Sep 2026 16:16:16 +0200 Subject: [PATCH 2/2] Update testvalueflow.cpp --- test/testvalueflow.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 618e16624d8..5807e86bee2 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -3257,6 +3257,17 @@ class TestValueFlow : public TestFixture { " if (x) {}\n" "}\n"; ASSERT_EQUALS(true, testValueOfXKnown(code, 5U, 0)); + + code = "struct S {\n" // #13844 + " int x{};\n" + " template \n" + " void f(T t) {\n" + " x = 0;\n" + " t();\n" + " if (x == 0) {}\n" + " }\n" + "};\n"; + ASSERT_EQUALS(false, testValueOfXKnown(code, 7U, 0)); } void valueFlowAfterSwap()