diff --git a/lib/checkclass.cpp b/lib/checkclass.cpp index fd5de98d8..b20fd14a4 100644 --- a/lib/checkclass.cpp +++ b/lib/checkclass.cpp @@ -2266,6 +2266,8 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool& 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()) + return false; } // non const pointer cast diff --git a/test/testclass.cpp b/test/testclass.cpp index 0db854351..6891f1b21 100644 --- a/test/testclass.cpp +++ b/test/testclass.cpp @@ -6245,6 +6245,14 @@ private: " void nextA() { return a--; }\n" "};"); ASSERT_EQUALS("[test.cpp:3]: (performance, inconclusive) Technically the member function 'Fred::nextA' can be static (but you may consider moving to unnamed namespace).\n", errout.str()); + + checkConst("struct S {\n" // #10077 + " int i{};\n" + " S& operator ++() { ++i; return *this; }\n" + " S operator ++(int) { S s = *this; ++(*this); return s; }\n" + " void f() { (*this)--; }\n" + "};\n"); + ASSERT_EQUALS("", errout.str()); } void constassign1() {