This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix PR c++/27422: ICE with invalid function argument
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 05 May 2006 13:57:59 +0200 (CEST)
- Subject: [patch] Fix PR c++/27422: ICE with invalid function argument
Since GCC 3.0 the C++ frontend ICEs on the following code snippet:
void foo(void i);
void bar() { foo(0); }
PR27422.cc:1: error: 'i' has incomplete type
PR27422.cc:1: error: invalid use of 'void'
PR27422.cc: In function 'void bar()':
PR27422.cc:2: internal compiler error: tree check: expected class
'type', have 'exceptional' (error_mark) in convert_arguments,
at cp/typeck.c:2718
Please submit a full bug report, [etc.]
This is because we try to convert "0" into the type of the first
argument of foo, which happens to be an error_mark_node.
The following patch fixes the ICE by not trying to do such a
conversion.
Bootstrapped and regtested on x86_64-unknown-linux-gnu.
Ok for mainline, 4.1 branch, and 4.0 branch?
Regards,
Volker
:ADDPATCH C++:
2006-05-05 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27422
* typeck.c (convert_arguments): Return early on args with
invalid types.
===================================================================
--- gcc/gcc/cp/typeck.c 2006-05-04 21:27:26 +0200
+++ gcc/gcc/cp/typeck.c 2006-05-04 21:30:14 +0200
@@ -2673,7 +2673,7 @@ convert_arguments (tree typelist, tree v
tree type = typetail ? TREE_VALUE (typetail) : 0;
tree val = TREE_VALUE (valtail);
- if (val == error_mark_node)
+ if (val == error_mark_node || type == error_mark_node)
return error_mark_node;
if (type == void_type_node)
===================================================================
2006-05-05 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
PR c++/27422
* g++.dg/conversion/void1.C: New test.
===================================================================
--- gcc/gcc/testsuite/g++.dg/conversion/void1.C 2003-09-23 19:59:22 +0200
+++ gcc/gcc/testsuite/g++.dg/conversion/void1.C 2006-05-04 21:34:35 +0200
@@ -0,0 +1,5 @@
+// PR c++/27422
+// { dg-do compile }
+
+void foo(void i); // { dg-error "incomplete type|invalid use" }
+void bar() { foo(0); }
===================================================================