http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56104



             Bug #: 56104

           Summary: Wrong "dereferencing type-punned pointer" warning

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: joerg.rich...@pdv-fs.de





cat > t.cc <<EOF

struct Foo

{

    void call()

    {}

};



template<class MEMSIG, MEMSIG MEMFUNC>

struct Wrap

{

    inline static void call( Foo cc )

    {

      (cc.*MEMFUNC)();     // <- warning here

    }

};



void bar()

{

  Wrap<void (Foo::*)(), &Foo::call>::call( Foo() );

}

EOF



/tools/pkg/gcc/4.7.2/bin/g++ -Wall -O2 -c -o t.o t.cc





Outputs:

t.cc: In instantiation of 'static void Wrap<MEMSIG, MEMFUNC>::call(Foo) [with

MEMSIG = void (Foo::*)(); MEMSIG MEMFUNC = &Foo::call]':

t.cc:18:38:   required from here

t.cc:12:7: warning: dereferencing type-punned pointer will break

strict-aliasing rules [-Wstrict-aliasing]



I think this warning is wrong.

Reply via email to