https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93490
Bug ID: 93490 Summary: -Wsuggest-attribute=const suggests const attribute for non-static member function Product: gcc Version: 9.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: christian.morales.vega at gmail dot com Target Milestone: --- I can't share the code triggering it. But gcc 9.2.1 from Fedora 31 is saying "function might be candidate for attribute ‘const’" for a member function. AFAIU since the member function takes the "this" pointer as argument it can't use the const attribute. FWIW the method - It already has the "pure" attribute - It just returns a reference to a member of the object - Is in a class derived from another using the CRTP It does it when building the class tests, with LTO. I have not checked, but it's possible the tests only ever use one object, so "this" couldn't ever change... in that specific code. If this is the problem I would argue that's a dangerous warning to give.