https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80711
--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #2) > Also useful would be to warn for members that don't access any state at all: > > struct indirect_cmp { > bool operator()(const X* l, const X* r) { return *l < *r; } > }; > > This comparison object should have a const-qualified member function to be > usable with associative containers such as std::set (see PR 83102 for > example). If I extend this to modify global state it's not pure, but should still be const-qualified: struct indirect_cmp { static int counter; bool operator()(const X* l, const X* r) { ++counter; return *l < *r; } }; int indirect_cmp::counter = 0; So the pure attribute isn't the right property.