The following code, compiled with -O2 -Wall (g++ 4.3 as of 20070607),
produces the following unexpected/annoying warning:
test_typeinfo.cpp: In function 'int main()':
test_typeinfo.cpp:5: warning: dereferencing type-punned pointer will break strict-aliasing rules
test_typeinfo.cpp:5: warning: unused variable 't'
~> cat test_typeinfo.cpp
const std::type_info & t = typeid(int);
Is this really meant to warn for such a code???
Confirmed, I have not looked into this close enough but this is a front-end bug as the type (and aliasing set) of the typeid variable is different from std::type_info's.
Short term at least, could be considered a duplicate of PR32256 (and PR32368).
*** Bug 33902 has been marked as a duplicate of this bug. ***
Testing a fix.
Subject: Bug 32260
Date: Thu Nov 1 22:50:32 2007
New Revision: 129835
* rtti.c (enum_tinfo_kind): Fix TK_TYPE_INFO_TYPE comment.
(typeid_ok_p): Use the same alias set for abi::__type_info_pseudo
as for std::type_info.
* g++.dg/rtti/typeid7.C: New test.
*** Bug 34066 has been marked as a duplicate of this bug. ***