egcs-971031: strange error in nested type template

Teemu Torma tot@Trema.COM
Thu Nov 6 00:43:00 GMT 1997


gcc -v
Reading specs from /usr/gnu/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.15/specs
gcc version egcs-2.90.15 971031 (gcc2-970802 experimental)

In the following code, I get a very strange error:

nested.cc:44: conflicting types for `struct S'
nested.cc:2: previous declaration as `typedef struct s1 * S'

I can see no reason for that.
---------------------------------------------------------------------------
// Here we declare ::S
typedef struct s1 *S;

struct s1
{
  int s;
};

struct A
{
  // Here we declare A::S
  typedef struct s1 *S;
};

template<class T, class U> class XX;

template<class T, class U>
class X
{
public:
  static T *do_something ();
  friend class T;
  friend class XX<T, U>;
};

struct N
{
  // Here we declare N::S
  class S
  {
  };

  // Should use N::S and A::S.
  typedef X<S, A::S> X_S;

  void bug ();
};

void
N::bug ()
{
  // X_S is template class X<N::S, A::S>
  // `s' is N::S.
  S *s = X_S::do_something ();
}
---------------------------------------------------------------------------

Teemu



More information about the Gcc-bugs mailing list