https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80311
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2018-04-23 Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #0) > struct X { > int i = 0; > int f() { return i; } > }; > > int main() { > X x; > using fp = int (*)(); > auto f = (fp)(&X::f); > return f(); > } > > This bogus attempt to use > https://gcc.gnu.org/onlinedocs/gcc/Bound-member-functions.html fails, > because there is no 'this' pointer provided for the call to the bound > function. I should have been clearer about how it "fails". It compiles (and gives a warning about use of the extension unless you silence it with -Wno-pmf-conversions) but then segfaults at runtime. > G++ should notice this and give a diagnostic, even with -Wno-pmf-conversions. The bug is that we shouldn't accept invalid uses of the extension. Valid uses of the extension should give warnings that can be controlled by -Wno-pmf-conversions as happens today, but invalid uses should be an error (maybe controllable by -fpermissive) not produce code that is guaranteed to segfault.