g++ rejects following IMHO valid code. int main() { const std::type_info& info = typeid(int []); return 0; }
Confirmed. I thought the type to which typeid is applied needs to be complete, but I can't find anything like this in the standard. W.
Here are some other cases to consider: #include <typeinfo> struct S; int main () { typeid (void); typeid (int []); typeid (S); typeid (S&); }
Never mind. The last two cases in my comment #2 are disallowed by the second to last sentence in 5.2.8, p4.
I have a draft...
Subject: Bug 29928 Author: paolo Date: Mon May 14 20:21:34 2007 New Revision: 124724 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124724 Log: /cp 2007-05-14 Paolo Carlini <pcarlini@suse.de> PR c++/29928 * rtti.c (get_tinfo_decl_dynamic, get_typeid): Try to complete the type only if is a class type (5.2.8/4). /testsuite 2007-05-14 Paolo Carlini <pcarlini@suse.de> PR c++/29928 * g++.dg/rtti/typeid5.C: New. Added: trunk/gcc/testsuite/g++.dg/rtti/typeid5.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/rtti.c trunk/gcc/testsuite/ChangeLog
Fixed for 4.3.0.