From 73da9622b978b3cc1ce9d7d906634b907e9e62f0 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 28 Apr 2026 10:28:58 +0200 Subject: [PATCH 1/2] Update testclass.cpp --- test/testclass.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/testclass.cpp b/test/testclass.cpp index 62cf32cfba5..2cecdfe80f6 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -6974,13 +6974,28 @@ class TestClass : public TestFixture { } void const101() { - checkConst("struct error {\n" + checkConst("struct error {\n" // #14450 " error() = default;\n" "};\n" "struct S : U {\n" " int f() { return this->error(); }\n" "};\n"); ASSERT_EQUALS("", errout_str()); + + checkConst("struct S {\n" // #14702 + " int i;\n" + " void f() {\n" + " S& r = *this;\n" + " r.i = 0;\n" + " }\n" + "};\n" + "struct T : std::array {\n" + " void g() {\n" + " for (int& r : *this)\n" + " r = 0;\n" + " }\n" + "};\n"); + ASSERT_EQUALS("", errout_str()); } void const_handleDefaultParameters() { From 7b3ad034a44052396e9d81a32c3990b13c23f668 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 28 Apr 2026 10:30:21 +0200 Subject: [PATCH 2/2] Update checkclass.cpp --- lib/checkclass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index 69cf8e70533..9fc9bdc7863 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2567,7 +2567,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, Member return false; if (Token::Match(tok1->previous(), "( this . * %var% )")) // call using ptr to member function TODO: check constness return false; - if (Token::simpleMatch(tok1->astParent(), "*") && tok1->astParent()->astParent() && tok1->astParent()->astParent()->isIncDecOp()) + if (Token::simpleMatch(tok1->astParent(), "*")) return false; }