Bug in 1.1b and 2.8.1 and snapshot 980921
Oskar Enoksson
osken393@student.liu.se
Wed Oct 14 13:36:00 GMT 1998
The bug seems to be related to the bug I reported in
http://www.cygnus.com/ml/egcs-bugs/1998-Sep/0956.html .
There are many combinations of array type template arguments
that cause the compiler to crash, silently emit wrong code or
just emit strange error messages. Inheritance need not necessarily
be involved, the problem seems to be with arrays.
I wish I knew enough about the compiler internals to be able to help
myself, but I don't (I've tried), so my only hope is that someone solves
this.
Here is another simple example that gives wrong code with egcs 1.1b and
gcc 2.8.1:
///// tst.cc /////
template<class T0>
class A {
public:
typedef T0 T;
};
template<int K>
class B {
typedef A<float[K]> BC;
};
template<int N, int M>
class C {
public:
typedef A<float[M]> AC;
};
int main() {
return sizeof(C<3,7>::AC::T);
}
///// end /////
> gcc -o tst tst.cc
> ./tst; echo $?
12
>
The return value should have been 28, assuming that sizeof(float)==4
but of some reason the two template arguments are swapped. If the
template declaration of class B is removed the problem disappears (!)
More information about the Gcc-bugs
mailing list