template bug.

Oskar Enoksson oseno@mai.liu.se
Mon Sep 28 07:44:00 GMT 1998


I have a problem with accessing a template class member of a partially
specialized template class, although I must admit I'm not 100% sure
that the code is 100% ANSI legal (please tell me!)

The problem occurs with snapshot 980921 aswell as 980914, but not
egcs 1.1. My platform is Digital Alpha ev56 OSF 4.0. The native OSF4.0
compiler cxx also accepts the code.

///// Error example tst.cc

template<int N, class T>
class A;

template<int N>
class A<N,int> {
public:
  template<int K>
  class B {
  public:
  };
};

main() {
  A<1,int>::B<1> x;
}

///// End of tst.cc

Compilation results follow:

> snapshot-980921/bin/gcc -c tst.cc

tst.cc: In function `int main()':
tst.cc:15: wrong number of template arguments (2, should be 1)
tst.cc:8: provided for `template <int const N> template <int const K>
A<N,int>::B<K>'
tst.cc:15: confused by earlier errors, bailing out

Also, if I change the declaration in main to

15c15
<   A<1,int>::B<1> x;
---
>   A<1,int>::template B<1> x;

the compiler responds

tst.cc: In function `int main()':
tst.cc:15: Internal compiler error.
tst.cc:15: Please submit a full bug report to `egcs-bugs@cygnus.com'.

Regards
/Oskar




More information about the Gcc-bugs mailing list