c++/3617: ICE when optimizing templated code

reichelt@igpm.rwth-aachen.de reichelt@igpm.rwth-aachen.de
Mon Jul 9 05:37:00 GMT 2001


>Number:         3617
>Category:       c++
>Synopsis:       ICE when optimizing templated code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Mon Jul 09 05:36:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Volker Reichelt
>Release:        gcc 3.0
>Organization:
>Environment:
i686-pc-linux-gnu, mips-sgi-irix6.5
>Description:
When compiling the following lines

template <int> struct A { template <class T> static void f(T); };
template <> template <class T> void A<0>::f(T) {}
void g() { A<0>::f(1); }

with -O3 turned on I get an ICE:

In file included from SpecialBug.cpp:3:
SpecialBug.cpp:1: Internal error: Segmentation fault
Please submit a full bug report,

etc. With -O2 or less the code compiles without problems.
In addition the error message itself is a little weird:
In spite of the message there is no included file at all.

And last but not least, there is one more problem:
With g++ 2.95.3 I get the following error message:

SpecialBug.cpp:2: template parameters specified in specialization
SpecialBug.cpp:2: no `static void A<0>::f(T)' member function declared in class `A<0>'
SpecialBug.cpp: In function `static void A<0>::f<T>(T)':
SpecialBug.cpp:2: must specialize `struct A<0>' before defining member `static void A<0>::f<T>(T)'

So either my code is illegal, in which case we have an
additional accepts-illegal bug for 3.0, or the code is
legal in fact, in which case we have a rejects-legal bug
for 2.95.3.

That's about three compiler bugs for three lines of code.
Is that a new record? ;-)

Greetings, Volker
>How-To-Repeat:
g++ -O3 -c SpecialBug.cpp
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list