This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: curried template inaccurate names
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Re: curried template inaccurate names
- From: Larry Evans <jcampbell3 at prodigy dot net>
- Date: Sat, 15 Jul 2000 13:54:47 -0500
- Followup-To: http://gcc.gnu.org/ml/gcc-bugs/2000-07/msg00393.html
- References: <396F68ED.E489D8BE@prodigy.net>
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>.