From 85ad1910b63ec07ef9891a0778e63eec32c00993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 15 Jul 2026 14:34:43 +0200 Subject: [PATCH 1/2] add test --- test/testother.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index 0b87a07f160..92fefb72fd3 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4146,6 +4146,14 @@ class TestOther : public TestFixture { " *o = 1;\n" "}\n"); ASSERT_EQUALS("", errout_str()); + + check("int f() {\n" + " int x = 0;\n" + " int& r(x);\n" + " r = x;\n" + " return r;\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void constParameterCallback() { From 76a93f028a5e2ec1b61e8a3e7a7664f23b2d7efe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludvig=20Gunne=20Lindstr=C3=B6m?= Date: Wed, 15 Jul 2026 14:27:09 +0200 Subject: [PATCH 2/2] fix --- lib/astutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 27a01ab0382..3c5c51498ba 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -3001,7 +3001,7 @@ bool isVariableChanged(const Variable * var, const Settings &settings, int depth const Token * start = var->declEndToken(); if (!start) return false; - if (Token::Match(start, "; %varid% =", var->declarationId())) + if (Token::Match(start, "; %varid% =", var->declarationId()) && !Token::simpleMatch(start->previous(), ")")) start = start->tokAt(2); if (Token::simpleMatch(start, "=")) { const Token* next = nextAfterAstRightmostLeafGeneric(start);