This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: curried template inaccurate names


The following is a simplified version of code producing the error:
=================================
template
  < typename S
  >
  struct
A
  {
  #define A__CTOR
  #ifdef A__CTOR
    //The following results in error compile-time error message:
    //  /tmp/ccWRHWY1.s:63: Fatal error: Symbol B<template <class> class C>::C<int>::C(void)

already defined.
    A(void)
      ;
  #endif
  };
template
  < template<typename S>class T
  >
  struct
B
  {
    template
      < typename U
      >
      struct
    C
      : public T<U>
      {
      typedef T<U> S;
      };
  };
typedef B<A> B1;
typedef B<B1::C> B2;
typedef B<B2::C> B3;
  int
main(void)
  {
  ; B2::C<int> c2
  ; B3::C<int> c3
  ; return 0
  ;}
===================================
Also, the comments provided in the original report of the bug are
expanded below:
=============================================
The name in the error message:
  B<template <class> class C>::C<int>::C(void)
suggests the compiler is not generating accurate names from the
template instantiations.  The above name should be either:

    B2::C<int>::C(void)
  = B<B1::C>::C<int>::C(void)
  = B<B<B<A>::C>::C>::C<int>::C(void)

    B3::C<int>::C(void)
  = B<B2::C>::C<int>::C(void)
  = B<B<B<B<A>::C>::C>::C>::C<int>::C(void)

To make clearer what is happening, the following trace of
the value for the typedef'ed S should help:

    B2::C<int>::S
  = B<B1::C>::C<int>::S
  = B1::C<int>

   B1::C<int>::S
 = B<A>::C<int>::S
 = A<int>

    B3::C<int>::S
  = B<B2::C>::C<int>::S
  = B2::C<int>

Thus, the superclass of B::C is always A<int>.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]