#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 &#8216;int main()&#8217;:
memb_fn.cpp:11: warning: format &#8216;%p&#8217; expects type
&#8216;void*&#8217;, but argument 3 has type &#8216;void (x::*)()&#8217;

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 &#8216;%p&#8217; expects type
                    &#8216;void*&#8217;, but argument has type &#8216;void
                    (x::*)()&#8217;
           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

Reply via email to