Bug 16964 - [3.4/4.0 regression] ICE in cp_parser_class_specifier due to redefinition
[3.4/4.0 regression] ICE in cp_parser_class_specifier due to redefinition
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
3.4.1
: P2 minor
: 3.4.2
Assigned To: Not yet assigned to anyone
: error-recovery, ice-on-invalid-code, monitored
Depends on:
Blocks: 12608
  Show dependency treegraph
 
Reported: 2004-08-10 14:10 UTC by Wolfgang Bangerth
Modified: 2004-10-30 21:11 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.3.4
Known to fail: 2.95.3 3.4.0 3.4.1 4.0.0
Last reconfirmed: 2004-08-10 16:38:56


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Bangerth 2004-08-10 14:10:35 UTC
This little piece of code, extracted from PR 16934, ICEs the 
compiler (note that the code is, of course, invalid): 
----------------- 
struct X  {  
    template<typename> struct Y { typedef int type; };  
    typedef Y<int>::type type;  
};  
  
template<> struct X::Y<int> { typedef int type; };  
----------------- 
 
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c a.cc 
a.cc:6: error: specialization of `X::Y<int>' after instantiation 
a.cc:6: error: redefinition of `struct X::Y<int>' 
a.cc:2: error: previous definition of `struct X::Y<int>' 
a.cc:6: internal compiler error: tree check: expected class 't', have 
'x' (error_mark) in cp_parser_class_specifier, at cp/parser.c:12371 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
This ICE is a regression in 3.4 and mainline against previous versions. 
 
W.
Comment 1 Volker Reichelt 2004-08-10 16:38:56 UTC
Confirmed.

Here's an even shorter snippet:

=====================
struct A
{
    struct B {};
};

struct A::B {};
=====================
Comment 2 Andrew Pinski 2004-08-10 21:37:51 UTC
: Search converges between 2003-08-12-trunk (#321) and 2003-08-13-trunk (#322).
Comment 3 CVS Commits 2004-08-11 22:13:40 UTC
Subject: Bug 16964

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-08-11 22:13:32

Modified files:
	gcc/cp         : ChangeLog parser.c pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: error16.C 
	gcc/testsuite/g++.dg/template: error14.C error15.C 

Log message:
	PR c++/16964
	* parser.c (cp_parser_class_specifier): Robustify.
	
	PR c++/16904
	* pt.c (tsubst_copy_and_build): Complain about invalid
	qualification.
	
	PR c++/16929
	* pt.c (tsubst_default_argument): Clear out current_class_ptr and
	current_class_ref while tsubsting.
	
	PR c++/16964
	* g++.dg/parse/error16.C: New test.
	
	PR c++/16904
	* g++.dg/template/error14.C: New test.
	
	PR c++/16929
	* g++.dg/template/error15.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4269&r2=1.4270
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.233&r2=1.234
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.901&r2=1.902
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4118&r2=1.4119
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error16.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error14.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error15.C.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 4 CVS Commits 2004-08-11 22:14:57 UTC
Subject: Bug 16964

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-08-11 22:14:44

Modified files:
	gcc/cp         : ChangeLog parser.c pt.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: error16.C 
	gcc/testsuite/g++.dg/template: error14.C error15.C 

Log message:
	PR c++/16964
	* parser.c (cp_parser_class_specifier): Robustify.
	
	PR c++/16904
	* pt.c (tsubst_copy_and_build): Complain about invalid
	qualification.
	
	PR c++/16929
	* pt.c (tsubst_default_argument): Clear out current_class_ptr and
	current_class_ref while tsubsting.
	
	PR c++/16964
	* g++.dg/parse/error16.C: New test.
	
	PR c++/16904
	* g++.dg/template/error14.C: New test.
	
	PR c++/16929
	* g++.dg/template/error15.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.140&r2=1.3892.2.141
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.36&r2=1.157.2.37
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.36&r2=1.816.2.37
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.243&r2=1.3389.2.244
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/error16.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error14.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/error15.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1

Comment 5 Mark Mitchell 2004-08-11 22:19:16 UTC
Fixed in GCC 3.4.2.