[Bug c++/80711] warn on non-const accessor member functions
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Nov 22 16:46:00 GMT 2017
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; }
^~~~~~~~~~~~
More information about the Gcc-bugs
mailing list