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