#include <cstdio> struct x { typedef void (x::*fn_ptr)(); void foo() { } }; int main() { x obj; x::fn_ptr f = &x::foo; std::printf( "&obj = %p, f = %p\n", &obj, f ); return 0; }
memb_fn.cpp: In function ‘int main()’: memb_fn.cpp:11: warning: format ‘%p’ expects type ‘void*’, but argument 3 has type ‘void (x::*)()’ pointer to member needs a context of course but it's in fact a pointer to method code, so casting to void* is imho acceptable. -- Summary: bogus diagnostic / format ‘%p’ expects type ‘void*’, but argument has type ‘void (x::*)()’ Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: minor Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pluto at agmk dot net GCC build triplet: x86-64-linux GCC host triplet: x86-64-linux GCC target triplet: x86-64-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28459