User account creation filtered due to spam.

Bug 15165 - [3.4/4.0 Regression] ICE in instantiate_template
Summary: [3.4/4.0 Regression] ICE in instantiate_template
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.1
Assignee: Mark Mitchell
URL:
Keywords: ice-on-valid-code
: 15038 16062 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-04-27 09:44 UTC by Sergei Kozachenko
Modified: 2004-10-30 21:11 UTC (History)
3 users (show)

See Also:
Host: Linux 2.6.5, pentium4
Target: Linux, pentium4
Build:
Known to work: 3.3.4
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-04-27 13:08:02


Attachments
file produced by gcc with option -save-temps (126.15 KB, text/plain)
2004-04-27 09:48 UTC, Sergei Kozachenko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Kozachenko 2004-04-27 09:44:10 UTC
crash while compiling
Comment 1 Sergei Kozachenko 2004-04-27 09:48:17 UTC
Created attachment 6170 [details]
file produced by gcc with option -save-temps

gcc building options was:
make CFLAGS='-O2 -march=pentium4 -mcpu=pentium4 -msse2 -funroll-all-loops
-mpreferred-stack-boundary=4 -mfpmath=sse -malign-double
-momit-leaf-frame-pointer -fomit-frame-pointer -fforce-mem -fforce-addr
-falign-functions -falign-labels -falign-loops -falign-jumps -frename-registers
-fno-cprop-registers -ffast-math' LIBCFLAGS='-g -O2'	    LIBCXXFLAGS='-g -O2
-fno-implicit-templates' bootstrap
Comment 2 Andrew Pinski 2004-04-27 11:52:44 UTC
Confirmed a regression but I have not reduced it yet.
Comment 3 Wolfgang Bangerth 2004-04-27 13:07:58 UTC
The testcase is here: 
----------------- 
struct S 
{ 
    template <class T> S(const T &e); 
}; 
 
int operator *(const double, const S &); 
 
template <class T> struct X { 
    enum { SIXTY_FOUR=64 }; 
 
    struct node { 
        unsigned char *ptr[sizeof(T)*SIXTY_FOUR]; 
        void add(const T &obj) {} 
    }; 
 
    node *head; 
}; 
 
void foo(int &c) { 
  X<int>().head->add(c); 
} 
------------------ 
 
g/x> /home/bangerth/bin/gcc-3.3.4-pre/bin/c++ -c x.cc 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
x.cc: In instantiation of `X<int>::node': 
x.cc:20:   instantiated from here 
x.cc:12: internal compiler error: in instantiate_template, at cp/pt.c:8669 
Please submit a full bug report, 
with preprocessed source if appropriate. 
See <URL:http://gcc.gnu.org/bugs.html> for instructions. 
 
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc 
x.cc: In instantiation of `X<int>::node': 
x.cc:20:   instantiated from here 
x.cc:12: internal compiler error: in instantiate_template, at cp/pt.c:8671 
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-04-27 13:24:14 UTC
Reduced a little further:
struct S 
{ 
    template <class T> S(const T &e);
};
int operator *(const double, const S &); 
template <class T>
struct X { 
    enum { SIXTY_FOUR=64 }; 
    struct node {
        unsigned char *ptr[sizeof(T)*SIXTY_FOUR]; // <-- catching operator* from above?
        void d() {}
    };
    node *head; 
};
template struct X<int>;
Comment 6 CVS Commits 2004-05-23 22:48:50 UTC
Subject: Bug 15165

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-05-23 22:48:38

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog pt.c 
Added files:
	gcc/testsuite/g++.dg/template: crash19.C 

Log message:
	PR c++/15165
	* pt.c (instantiate_template): Robustify.
	
	PR c++/15165
	* g++.dg/template/crash19.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3775&r2=1.3776
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/crash19.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.4055&r2=1.4056
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.853&r2=1.854

Comment 7 Mark Mitchell 2004-05-23 22:50:10 UTC
Fixed in GCC 3.4.1.
Comment 8 Mark Mitchell 2004-05-23 23:04:17 UTC
*** Bug 15038 has been marked as a duplicate of this bug. ***
Comment 9 Andrew Pinski 2004-06-18 15:54:53 UTC
*** Bug 16062 has been marked as a duplicate of this bug. ***