https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80711
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- There is a warning like that in the middle-end: -Wsuggest-attribute=pure. Unfortunately, it's only good for functions that are actually emitted (i.e., not for C++ inline functions). $ cat t.C && gcc -O2 -S -Wall -Wsuggest-attribute=pure t.C typedef int X; struct indirect_cmp { bool operator()(const X* l, const X* r); }; bool indirect_cmp::operator()(const X* l, const X* r) { return *l < *r; } t.C: In member function ‘bool indirect_cmp::operator()(const X*, const X*)’: t.C:7:6: warning: function might be candidate for attribute ‘pure’ [-Wsuggest-attribute=pure] bool indirect_cmp::operator()(const X* l, const X* r) { return *l < *r; } ^~~~~~~~~~~~