Bug 37037 - [4.3/4.4/4.5 Regression] ICE on template class member function definition after explicit template class instantation
Summary: [4.3/4.4/4.5 Regression] ICE on template class member function definition aft...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.1
: P2 normal
Target Milestone: 4.3.5
Assignee: Jason Merrill
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2008-08-06 13:43 UTC by Vincent Zweije
Modified: 2009-11-12 23:27 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.0.1
Known to fail: 4.4.0 4.1.1 4.3.3
Last reconfirmed: 2009-11-12 22:17:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Zweije 2008-08-06 13:43:21 UTC
Following snippet causes compiler to produce internal compiler error:

typedef void F(void);
template <typename T> struct S 
{
    static F f;
};
template class S<int>;
template <class T> void S<T>::f(void)
{}

I'm not sure it is valid to define S<T>::f() after instantiating the class, but even if not, an ICE is not a proper response for a compiler in any case. #24511 mentions that all member templates (template members?) must be defined before explicit instantiation although I don't read that per se in my copy of the standard.

There might be a vague relation to #24791 if there is g++-internal confusion about f being a static data member. This confusion might be exhibited in #33972 as well.

Ciao.
Vincent.
Comment 1 Vincent Zweije 2008-08-06 13:48:42 UTC
$g++ -o crash.o crash.cpp
+ /usr/bin/g++-4.3 -L/home/vincent/lib32 -o crash.o crash.cpp
crash.cpp: In static member function ‘static void S<T>::f() [with T = int]’:
crash.cpp:6:   instantiated from here
crash.cpp:4: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.3/README.Bugs> for instructions.
$g++ -v
+ /usr/bin/g++-4.3 -L/home/vincent/lib32 -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.3.1-2' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-cld --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.3.1 (Debian 4.3.1-2) 
$
Comment 2 Andrew Pinski 2008-08-11 00:21:28 UTC
It compiled with 4.0.1.
Comment 3 David Fang 2008-09-27 21:48:30 UTC
original testcase ICEs 4.3.2 also

fang% g++-4 -v 
Using built-in specs.
Target: powerpc-apple-darwin8
Configured with: ../gcc-4.3.2/configure --prefix=/sw --prefix=/sw/lib/gcc4.3 --mandir=/sw/share/man --infodir=/sw/share/info --enable-languages=c,c++,fortran,objc,java --build=powerpc-apple-darwin8 --with-gmp=/sw --with-libiconv-prefix=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --disable-libjava-multilib
Thread model: posix
gcc version 4.3.2 (GCC) 
fang% g++-4 -ansi -pedantic-errors -c temp.cc -o temp.o
temp.cc: In static member function 'static void S<T>::f() [with T = int]':
temp.cc:6:   instantiated from here
temp.cc:4: internal compiler error: Bus error
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instruction
Comment 4 Andrew Pinski 2008-12-27 14:55:24 UTC
Confirmed.
Comment 5 Paolo Carlini 2009-01-29 11:23:58 UTC
Are we really sure this is invalid? For one, EDG doesn't agree...
Comment 6 Joseph S. Myers 2009-03-31 20:57:46 UTC
Closing 4.2 branch.
Comment 7 Richard Biener 2009-08-04 12:29:23 UTC
GCC 4.3.4 is being released, adjusting target milestone.
Comment 8 Jason Merrill 2009-11-12 22:50:30 UTC
Subject: Bug 37037

Author: jason
Date: Thu Nov 12 22:49:59 2009
New Revision: 154131

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154131
Log:
	PR c++/37037
	* decl.c (grokdeclarator): Don't generate a void PARM_DECL.

Added:
    trunk/gcc/testsuite/g++.dg/template/typedef21.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 9 Jason Merrill 2009-11-12 23:22:14 UTC
Subject: Bug 37037

Author: jason
Date: Thu Nov 12 23:21:55 2009
New Revision: 154134

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154134
Log:
	PR c++/37037
	* decl.c (grokdeclarator): Don't generate a void PARM_DECL.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef21.C
Modified:
    branches/gcc-4_4-branch/gcc/cp/ChangeLog
    branches/gcc-4_4-branch/gcc/cp/decl.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog

Comment 10 Jason Merrill 2009-11-12 23:22:30 UTC
Subject: Bug 37037

Author: jason
Date: Thu Nov 12 23:22:10 2009
New Revision: 154135

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154135
Log:
	PR c++/37037
	* decl.c (grokdeclarator): Don't generate a void PARM_DECL.

Added:
    branches/gcc-4_3-branch/gcc/testsuite/g++.dg/template/typedef21.C
Modified:
    branches/gcc-4_3-branch/gcc/cp/ChangeLog
    branches/gcc-4_3-branch/gcc/cp/decl.c
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 11 Jason Merrill 2009-11-12 23:27:13 UTC
Fixed.