[patch] Fix PR c++/28109: ICE with typeid of incomplete type
Volker Reichelt
reichelt@igpm.rwth-aachen.de
Wed Jun 21 10:58:00 GMT 2006
Since GCC 3.4.0 the C++ frontend ICEs on the following code snippet:
#include <typeinfo>
struct A;
void foo()
{
A a; // { dg-error "incomplete type" }
typeid (a);
}
bug.cc: In function 'void foo()':
bug.cc:7: error: aggregate 'A a' has incomplete type and cannot be defined
bug.cc:8: internal compiler error: tree check: expected class 'type', have 'exceptional' (error_mark) in get_tinfo_decl_dynamic, at cp/rtti.c:238
Please submit a full bug report, [etc.]
We already have a sanity check at the beginning of get_tinfo_decl_dynamic,
but expressions with invalid types still slip through. The patch fixes the
ICE by making the check more robust.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline, 4.1 branch, and 4.0 branch?
Regards,
Volker
:ADDPATCH C++:
2006-06-21 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/28109
* rtti.c (get_tinfo_decl_dynamic): Robustify.
===================================================================
--- gcc/gcc/cp/rtti.c (revision 114800)
+++ gcc/gcc/cp/rtti.c (working copy)
@@ -228,7 +228,7 @@ get_tinfo_decl_dynamic (tree exp)
tree type;
tree t;
- if (exp == error_mark_node)
+ if (error_operand_p (exp))
return error_mark_node;
/* peel back references, so they match. */
===================================================================
2006-06-21 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/28109
* g++.dg/rtti/incomplete1.C: New test.
===================================================================
--- gcc/gcc/testsuite/g++.dg/rtti/incomplete1.C 2005-08-29 00:25:44 +0200
+++ gcc/gcc/testsuite/g++.dg/rtti/incomplete1.C 2006-06-20 15:49:07 +0200
@@ -0,0 +1,12 @@
+// PR c++/28109
+// { dg-do compile }
+
+#include <typeinfo>
+
+struct A;
+
+void foo()
+{
+ A a; // { dg-error "incomplete type" }
+ typeid (a);
+}
===================================================================
More information about the Gcc-patches
mailing list