This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug c++/19143] New: [4.0 regression] ICE on invalid template parameter
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org, gcc-bugzilla at gcc dot gnu dot org
- Date: 29 Dec 2004 06:03:40 -0200
- Subject: Re: [Bug c++/19143] New: [4.0 regression] ICE on invalid template parameter
- Organization: Red Hat Global Engineering Services Compiler Team
- References: <20041224013907.19143.reichelt@gcc.gnu.org>
On Dec 23, 2004, "reichelt at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> wrote:
> The following invalid code snippet triggers an ICE on mainline:
> ==============================================
> template<int> struct A;
> template<> struct A<template> {};
> ==============================================
> bug.cc:2: error: missing '>' to terminate the template argument list
> bug.cc:2: error: template argument 1 is invalid
> bug.cc:2: error: missing '>' to terminate the template argument list
> bug.cc:2: error: template argument 1 is invalid
> bug.cc:2: error: 'A' is not a template
> bug.cc:2: error: missing '>' to terminate the template argument list
> bug.cc:2: internal compiler error: Segmentation fault
> Please submit a full bug report, [etc.]
> Alexandre, this was causes by your path for PR18757:
> http://gcc.gnu.org/ml/gcc-cvs/2004-12/msg00382.html
> Could you please have a look?
This patch fixes it, but I'm not entirely sure this is the best
location for this test. Tested on amd64-linux-gnu, no failures. Ok
to install?
Index: gcc/cp/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* pt.c (redeclare_class_template): Don't crash when parms
parsing failed.
Index: gcc/cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.962
diff -u -p -r1.962 pt.c
--- gcc/cp/pt.c 23 Dec 2004 19:54:08 -0000 1.962
+++ gcc/cp/pt.c 29 Dec 2004 07:32:11 -0000
@@ -3234,6 +3234,11 @@ redeclare_class_template (tree type, tre
type. */
return;
+ /* If the template parameters could not be parsed, assume we already
+ issued an error and bail out without crashing. */
+ if (! parms)
+ return;
+
parms = INNERMOST_TEMPLATE_PARMS (parms);
tmpl_parms = DECL_INNERMOST_TEMPLATE_PARMS (tmpl);
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}