From 9d3224901db6fb138c38bbd8836fde8be949024c Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 21 Apr 2026 12:31:33 +0200 Subject: [PATCH 1/2] Update astutils.cpp --- lib/astutils.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 2a4de18b2c0..8712800a867 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2518,8 +2518,6 @@ bool isMutableExpression(const Token* tok) if (tok->astOperand1() && Token::simpleMatch(tok, "[")) return isMutableExpression(tok->astOperand1()); if (const Variable* var = tok->variable()) { - if (var->nameToken() == tok) - return false; if (var->isConst() && !var->isPointer() && (!var->isArray() || !var->isArgument())) return false; } From dce479db743f99ccb21686f1dee58c6b18aaad6d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 21 Apr 2026 12:36:46 +0200 Subject: [PATCH 2/2] Update testother.cpp --- test/testother.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index bac5dfbdf7f..1b53a5795e1 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -12651,6 +12651,24 @@ class TestOther : public TestFixture { " }\n" "}\n"); ASSERT_EQUALS("[test.cpp:4:36]: (warning) Access of moved variable 'l'. [accessMoved]\n", errout_str()); + + check("struct S {\n" // #13179 + " operator bool() const { return !m.empty(); }\n" + " std::string m;\n" + "};\n" + "S get();\n" + "void set(S);\n" + "void f() {\n" + " while (S s = get()) {\n" + " set(std::move(s));\n" + " }\n" + "}\n" + "void g() {\n" + " while (S s{ get() }) {\n" + " set(std::move(s));\n" + " }\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void moveCallback()