Bug 8149 - ICE on incomplete type
Summary: ICE on incomplete type
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2002-10-04 15:16 UTC by sneechy
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description sneechy 2002-10-04 15:16:01 UTC
The following four lines of code:

#include <typeinfo>
struct B { template <typename U> struct C; };
template <typename T> struct A { typedef typename T::C V; };
void f () { A<B>::V p; }

Result in an internal compiler error:
"internal error: Segmentation fault"

Release:
gcc version 3.2 (mingw special 20020817-1)

Environment:
Windows XP, gcc configure options: --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=f77,c++,objc,ada --disable-win32-registry --disable-shared

How-To-Repeat:
Compile the four lines of code (see problem description).
Comment 2 Volker Reichelt 2002-10-23 13:36:45 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed.
    
    The example can be reduced a little bit further:
    
    -------------------------snip here-------------------------
    struct B { template <typename U> struct C; };
    template <typename T> struct A { typedef typename T::C V; };
    A<B>::V p;
    -------------------------snip here-------------------------
    
    Compiling this with "g++ -c" using the 3.2-branch or the main trunk
    results in an ICE (checked on i686-pc-linux-gnu). With gcc 3.0.x or
    2.95.x I get an error message:
    
    PR8149.cc:3: aggregate `B::C<U> p' has incomplete type and cannot be 
       initialized
    PR8149.cc:3: storage size of `p' isn't known
    
    Changing "struct C;" to "struct C{};" in the first line to get rid of this
    message (the rest of the code still remains illegal) causes gcc 3.0.x to
    issue an ICE and 2.95.x to issue an assembler error.
Comment 3 Mark Mitchell 2002-10-30 16:07:15 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed in GCC 3.2.1.
Comment 4 Mark Mitchell 2002-10-31 00:02:36 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8149
Date: 31 Oct 2002 00:02:36 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	mmitchel@gcc.gnu.org	2002-10-30 16:02:36
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 	gcc/cp         : ChangeLog decl.c typeck2.c 
 Added files:
 	gcc/testsuite/g++.dg/template: complit1.C typename4.C 
 
 Log message:
 	PR c++/8160
 	* g++.dg/template/complit1.C: New test.
 	
 	PR c++/8149
 	* g++.dg/template/typename4.C: Likewise.
 	
 	PR c++/8160
 	* typeck2.c (process_init_constructor): Call complete_array_type.
 	
 	PR c++/8149
 	* decl.c (make_typename_type): Issue errors about invalid results.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.43&r2=1.1672.2.166.2.44
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/complit1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/typename4.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.37&r2=1.2685.2.114.2.38
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.866.2.36.2.11&r2=1.866.2.36.2.12
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.117.2.2.2.1&r2=1.117.2.2.2.2
 

Comment 5 Mark Mitchell 2002-10-31 00:02:36 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8149
Date: 31 Oct 2002 00:02:36 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_2-branch
 Changes by:	mmitchel@gcc.gnu.org	2002-10-30 16:02:36
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 	gcc/cp         : ChangeLog decl.c typeck2.c 
 Added files:
 	gcc/testsuite/g++.dg/template: complit1.C typename4.C 
 
 Log message:
 	PR c++/8160
 	* g++.dg/template/complit1.C: New test.
 	
 	PR c++/8149
 	* g++.dg/template/typename4.C: Likewise.
 	
 	PR c++/8160
 	* typeck2.c (process_init_constructor): Call complete_array_type.
 	
 	PR c++/8149
 	* decl.c (make_typename_type): Issue errors about invalid results.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.1672.2.166.2.43&r2=1.1672.2.166.2.44
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/complit1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/typename4.C.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=NONE&r2=1.1.2.1
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.2685.2.114.2.37&r2=1.2685.2.114.2.38
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.866.2.36.2.11&r2=1.866.2.36.2.12
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_2-branch&r1=1.117.2.2.2.1&r2=1.117.2.2.2.2
 

Comment 6 Mark Mitchell 2002-10-31 00:04:13 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8149
Date: 31 Oct 2002 00:04:13 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-10-30 16:04:13
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 	gcc/cp         : ChangeLog decl.c typeck2.c 
 Added files:
 	gcc/testsuite/g++.dg/template: complit1.C typename4.C 
 
 Log message:
 	PR c++/8160
 	* typeck2.c (process_init_constructor): Call complete_array_type.
 	
 	PR c++/8149
 	* decl.c (make_typename_type): Issue errors about invalid results.
 	
 	PR c++/8160
 	* g++.dg/template/complit1.C: New test.
 	
 	PR c++/8149
 	* g++.dg/template/typename4.C: Likewise.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2193&r2=1.2194
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/complit1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/typename4.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3032&r2=1.3033
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.958&r2=1.959
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck2.c.diff?cvsroot=gcc&r1=1.131&r2=1.132
 

Comment 7 Mark Mitchell 2002-10-31 00:04:13 UTC
From: mmitchel@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c++/8149
Date: 31 Oct 2002 00:04:13 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	mmitchel@gcc.gnu.org	2002-10-30 16:04:13
 
 Modified files:
 	gcc/testsuite  : ChangeLog 
 	gcc/cp         : ChangeLog decl.c typeck2.c 
 Added files:
 	gcc/testsuite/g++.dg/template: complit1.C typename4.C 
 
 Log message:
 	PR c++/8160
 	* typeck2.c (process_init_constructor): Call complete_array_type.
 	
 	PR c++/8149
 	* decl.c (make_typename_type): Issue errors about invalid results.
 	
 	PR c++/8160
 	* g++.dg/template/complit1.C: New test.
 	
 	PR c++/8149
 	* g++.dg/template/typename4.C: Likewise.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2193&r2=1.2194
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/complit1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/typename4.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3032&r2=1.3033
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.958&r2=1.959
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/typeck2.c.diff?cvsroot=gcc&r1=1.131&r2=1.132