Bug in 1.1b and 2.8.1 and snapshot 980921

Oskar Enoksson osken393@student.liu.se
Tue Oct 13 11:54:00 GMT 1998


Is this bug reported? It generates wrong code on both
alpha-ev56-osf4.0d and i586-linux with egcs 1.1b. The error
is also in gcc 2.8.1 and in snapshot 980921 (at least on the alpha).

#include <iostream>

template<int N, class T> // Base class
class A { public: static int n() { return sizeof(T); } };

template<int N> // Derived #1
class B: public A<N,float[N]> {};

template<int N, int M> // Derived #2 (wrong!)
class C: public A<N,float[M]> {};

main() {
  cout<<C<3,1>::n()<<endl; 
}

The is 3*sizeof(float), but should be 1*sizeof(float)!

Apparently the compiler is confused by having two classes inheriting
from the same baseclass template, because if I comment out the definition
of class B the generated code is correct.

Regards.

*/              Oskar Enoksson, Linkoping, Sweden                  /*




More information about the Gcc-bugs mailing list