From 2c4eeea743d7f01c0609f2ab9f5bbe09b377eb0b Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 27 Nov 2026 15:04:32 +0100 Subject: [PATCH 1/2] Update astutils.cpp --- lib/astutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index a08d86a2f86..9f4e97df827 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -2642,7 +2642,7 @@ bool isVariableChanged(const Token *tok, int indirect, const Settings &settings, if (!tok->isMutableExpr()) return false; - if (isConstVarExpression(tok)) + if (indirect == 0 && isConstVarExpression(tok)) return false; const Token *tok2 = tok; From 72c8fbddd3c380c791ad9a1d1238aefcf92da920 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Fri, 27 Nov 2026 15:07:31 +0100 Subject: [PATCH 2/2] Update testother.cpp --- test/testother.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index 085b39cfffb..88ae900225c 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4300,6 +4300,11 @@ class TestOther : public TestFixture { "}\n"); ASSERT_EQUALS("[test.cpp:3:7]: (style) Variable 'a' can be declared as const array [constVariable]\n", errout_str()); + + check("void f(V& v) {\n" + " std::sort(&v(1), &v(10));\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void constParameterCallback() {