The following invalid code snippet causes an ICE on mainline: ============================ int foo; template<int> void foo() {} ============================ The error message reads: bug.cc:2: error: 'template<int <anonymous> > void foo()' redeclared as different kind of symbol bug.cc:1: error: previous declaration of 'int foo' Internal compiler error: Error reporting routines re-entered. Please submit a full bug report, [etc.] The following patch fixes the problem for me. I haven't done any regtesting, though. =================================================================== --- gcc/gcc/cp/decl.c 27 Jan 2005 07:32:20 -0000 1.1355 +++ gcc/gcc/cp/decl.c 15 Feb 2005 19:18:28 -0000 @@ -9917,7 +9917,11 @@ start_preparsed_function (tree decl1, tr class scope, current_class_type will be NULL_TREE until set above by push_nested_class.) */ if (processing_template_decl) - decl1 = push_template_decl (decl1); + { + tree newdecl1 = push_template_decl (decl1); + if (newdecl1 != error_mark_node) + decl1 = newdecl1; + } /* We are now in the scope of the function being defined. */ current_function_decl = decl1; ===================================================================
Confirmed: : Search converges between 2004-02-01-trunk (#445) and 2004-03-01-trunk (#446).
Patch here: http://gcc.gnu.org/ml/gcc-patches/2005-02/msg01132.html
"But, that's too complicated for Stage 3. Your patch is OK."
Subject: Bug 19980 CVSROOT: /cvs/gcc Module name: gcc Changes by: reichelt@gcc.gnu.org 2005-03-22 15:07:04 Modified files: gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: redecl3.C Log message: PR c++/19980 * decl.c (start_preparsed_function): Robustify. * g++.dg/template/redecl3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4672&r2=1.4673 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1380&r2=1.1381 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5195&r2=1.5196 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/redecl3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Subject: Bug 19980 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-4_0-branch Changes by: reichelt@gcc.gnu.org 2005-03-22 15:13:35 Modified files: gcc/cp : ChangeLog decl.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/template: redecl3.C Log message: PR c++/19980 * decl.c (start_preparsed_function): Robustify. * g++.dg/template/redecl3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.4648.2.16&r2=1.4648.2.17 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1371.2.4&r2=1.1371.2.5 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.61&r2=1.5084.2.62 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/redecl3.C.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1
Fixed.
Hi Volker: probably your patch fixes c++/20443 too! Can you check?
*** Bug 20443 has been marked as a duplicate of this bug. ***