c++/240: problems with element templates, incl ICE
r.spatschek@fz-juelich.de
r.spatschek@fz-juelich.de
Wed May 24 07:36:00 GMT 2000
>Number: 240
>Category: c++
>Synopsis: problems with element templates, incl ICE
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed May 24 07:36:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Robert Spatschek
>Release: gcc version egcs-2.91.66 19990314
>Organization:
>Environment:
SuSE Linux 6.3 Kernel 2.2.14
DEC alpha OSF1 4.0
>Description:
Several mysterious things happens with the code below:
1) comment out lines a, b, c, d (only e remains for simplicity)
call of nonexisting member function h of class A gives an ICE.
[229] spatsche@iff645% gcc -o template1 template1.cpp
template1.cpp: In function `int main()':
template1.cpp:19: Internal compiler error.
template1.cpp:19: Please submit a full bug report to `egcs-bugs@egcs.cygnus.com'.
template1.cpp:19: See <URL: http://egcs.cygnus.com/faq.html#bugreport > for details.
2) comment out lines c, e (a, b, d remain)
linking doesn't work on DEC alpha OSF1:
[226] spatsche@iff645% gcc -o template1 template1.cpp
/bin/ld:
Unresolved:
cout
ostream::operator<<(char const *)
collect2: ld returned 1 exit status
Anyway, this combination works pretty well with Linux.
3) comment out line e (a, b, c, d remain)
call of A::f() works from the inside of the struct (see line b)
(of course again not on the DEC),
but compiler rejects line c:
[227] spatsche@iff645% gcc -o template1 template1.cpp
template1.cpp: In function `int main()':
template1.cpp:17: parse error before `>'
For comparison: This works with the DEC C++ compiler.
Sorry that I decided to mention those three symptoms
together within one bug report.
>How-To-Repeat:
// template1.cpp
#include <iostream>
struct A
{
template <class T> void f() {cout << "Hello\n";} // line a
void g() {f<int>();} // line b
};
template <class T> void h()
{
}
int main()
{
A a;
a.f<int>(); // line c
a.g(); // line d
a.h<int>(); // line e
}
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list