Bug 16904 - [3.3/3.4/4.0 regression] ICE in finish_class_member_access_expr, at cp/typeck.c:1945
[3.3/3.4/4.0 regression] ICE in finish_class_member_access_expr, at cp/typeck...
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
4.0.0
: P2 normal
: 3.4.2
Assigned To: Not yet assigned to anyone
: ice-on-invalid-code, monitored
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-08-06 19:30 UTC by Václav Zeman
Modified: 2004-10-30 21:11 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 3.2.3
Known to fail: 3.3.3 3.4.0 4.0.0
Last reconfirmed: 2004-08-06 19:57:08


Attachments
Testcase (156 bytes, text/plain)
2004-08-06 19:31 UTC, Václav Zeman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Václav Zeman 2004-08-06 19:30:47 UTC
I've made a typo and as result I've produced this ICE:

wilx@logout:::~/tmp> g++ -c testcase.cxx
testcase.cxx: In member function `void X<T>::handler() [with T = S]':
testcase.cxx:16:   instantiated from here
testcase.cxx:9: error: no type named `BaseType' in `struct S'
testcase.cxx:9: internal compiler error: in finish_class_member_access_expr, at
cp/typeck.c:1945
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.


Configuration: 
wilx@logout:::~/tmp> gcc -v
Reading specs from /home/4/wilx/lib/gcc/i386-unknown-freebsd4.10/3.5.0/specs
Configured with: ../srcdir/configure --disable-nls
--enable-version-specific-runtime-libs --enable-dwarf2 --with-cpu=pentium3
--with-arch=pentium3 --with-system-zlib --disable-shared --prefix=/home/4/wilx
--enable-languages=c,c++,objc --disable-sjlj-exceptions
--enable-shared=libstdc++ --enable-shared=libobjc --with-gc=zone
Thread model: posix
gcc version 3.5.0 20040803 (experimental)
Comment 1 Václav Zeman 2004-08-06 19:31:33 UTC
Created attachment 6896 [details]
Testcase
Comment 2 Wolfgang Bangerth 2004-08-06 19:57:08 UTC
Confirmed, an ICE after error. This is a regression over 3.3.4, which 
only issued the error. 
 
The testcase in the attachment is already nice and small. 
 
W. 
Comment 3 Wolfgang Bangerth 2004-08-06 19:59:37 UTC
It is, however, possible to make it even smaller :-) 
------------------ 
template <typename T> struct X { 
  X () { 
    this->T::handler (); 
  } 
}; 
 
template struct X<int>; 
-------------------- 
 
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc 
x.cc: In constructor `X<T>::X() [with T = int]': 
x.cc:7:   instantiated from here 
x.cc:3: internal compiler error: in finish_class_member_access_expr, at 
cp/typeck.c:1945 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
W. 
Comment 4 Andrew Pinski 2004-08-06 20:34:54 UTC
Note this is invalid code as T is not a base class of the template, we should have rejected it before got 
to this point.
Comment 5 Volker Reichelt 2004-08-06 23:58:14 UTC
The following example is even smaller,
and it crashes the compiler since gcc 3.3:

================================
template<typename T> struct X
{
    X() { this->T::i; }
};

X<int> x;
================================
Comment 6 Andrew Pinski 2004-08-10 01:43:53 UTC
: Search converges between 2002-08-04-trunk (#84) and 2002-08-11-trunk (#85).
Comment 7 CVS Commits 2004-08-11 22:13:40 UTC
Subject: Bug 16904

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 8 CVS Commits 2004-08-11 22:14:55 UTC
Subject: Bug 16904

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 9 Mark Mitchell 2004-08-11 22:19:48 UTC
Fixed in GCC 3.4.2.