This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR c++/29291: ICE on invalid use of new
- From: reichelt at igpm dot rwth-aachen dot de
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 29 Sep 2006 22:54:23 +0200 (CEST)
- Subject: [patch] Fix PR c++/29291: ICE on invalid use of new
The following invalid code snippet triggers an ICE since GCC 4.2.0:
template<int> void foo()
{
new int(;
}
bug.cc: In function 'void foo()':
bug.cc:3: error: expected primary-expression before ';' token
bug.cc:3: internal compiler error: tree check: expected tree_list, have
error_mark in any_type_dependent_arguments_p, at cp/pt.c:13017
Please submit a full bug report, [etc.]
This is similar to PR 28593, and so is the fix: The patch just improves
the sanity checks at the beginning of build_new.
Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for mainline?
Regards,
Volker
:ADDPATCH C++:
2006-09-26 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/29291
* init.c (build_new): Check for invalid init.
===================================================================
--- gcc/gcc/cp/init.c 2006-09-27 04:20:35 +0200
+++ gcc/gcc/cp/init.c 2006-09-27 04:20:22 +0200
@@ -2075,7 +2075,8 @@ build_new (tree placement, tree type, tr
tree orig_nelts;
tree orig_init;
- if (placement == error_mark_node || type == error_mark_node)
+ if (placement == error_mark_node || type == error_mark_node
+ || init == error_mark_node)
return error_mark_node;
orig_placement = placement;
===================================================================
2006-09-26 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/29291
* g++.dg/parse/new4.C: New test.
===================================================================
--- gcc/gcc/testsuite/g++.dg/parse/new4.C 2003-09-23 19:59:22 +0200
+++ gcc/gcc/testsuite/g++.dg/parse/new4.C 2006-09-27 04:32:02 +0200
@@ -0,0 +1,7 @@
+// PR c++/29291
+// { dg-do compile }
+
+template<int> void foo()
+{
+ new int(; // { dg-error "before" }
+}
===================================================================