[Bug c++/34066] New: typeid breaks aliasing rules, according to g++

guillaume dot melquiond at ens-lyon dot fr gcc-bugzilla@gcc.gnu.org
Sun Nov 11 13:59:00 GMT 2007


I am unable to get GCC 4.3 (20071101) to compile some code involving typeid.
The testcase below compiles just fine with older GCC 4.1 and 4.2. The "name()"
call is just here so that older GCCs do not complain about the useless
statement. Even when the body of the function contains "typeid(int);" only, GCC
4.3 still complains about a pointer being dereferenced. So typeid is unusable
with GCC 4.3.

#include <typeinfo>
void f() { typeid(int).name(); }

test.cpp:2: warning: dereferencing type-punned pointer will break
strict-aliasing rules


-- 
           Summary: typeid breaks aliasing rules, according to g++
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: guillaume dot melquiond at ens-lyon dot fr


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



More information about the Gcc-bugs mailing list