If you call a method on a subobject which takes a member of a different subobject by non-const reference, cppcheck reports that the top method can be const:
struct Foo { Bar bar; Baz baz; int i{}; void getInt() { bar.getInt(baz.i); } // Technically the member function 'Foo::getInt' can be const }; struct Bar { int j = 5; void getInt(int& i) const { i += j; } }; struct Baz { int i{}; };
This still reproduces with v2.3.
I created a ticket: https://trac.cppcheck.net/ticket/10146
Log in to post a comment.
If you call a method on a subobject which takes a member of a different subobject by non-const reference, cppcheck reports that the top method can be const:
This still reproduces with v2.3.
I created a ticket: https://trac.cppcheck.net/ticket/10146