possible template-parameterized-template bug
Paul Burchard
burchard@math.ucla.edu
Wed Jul 14 07:51:00 GMT 1999
Consider the following small C++ program:
template<class X> class A {};
template<class Y> class B {};
template<template<class XX> class AA> class C {
class D {} d;
class E : public B<D> {} e;
};
int main() { C<A> c; }
Egcs-1.1.2 complains that this program defines the following
twice (complete output below):
template <class XX> template <class X> class A<X>
I don't believe that this program is supposed to define such a
template at all. XX is only a name for the parameter of C's
parameter template AA<>, which should be identified with the
parameter X of the specific template A<> upon instantiation.
Passing A as a parameter to C should not suddenly turn it
into a member template class of the template class C.
(Apologies if this is just my misunderstanding of the C++ standard.)
Here is the complete output:
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -D__ELF__ -Dunix -Di386 -D__i386__ -Dlinux -D__ELF__ -D__unix__ -D__i386__ -D__i386__ -D__linux__ -D__unix -D__i386 -D__linux -Asystem(posix) -D__EXCEPTIONS -Asystem(unix) -Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ egcs-bug.2.C egcs-bug.2.ii
GNU CPP version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/usr/include/g++-2
/usr/i386-redhat-linux/include
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/include
/usr/include
End of search list.
/usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/cc1plus egcs-bug.2.ii -quiet -dumpbase egcs-bug.2.cc -version -o egcs-bug.2.s
GNU C++ version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) (i386-redhat-linux) compiled by GNU C version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release).
egcs-bug.2.C: In instantiation of `C<A>::E':
egcs-bug.2.C:14: instantiated from `C<A>'
egcs-bug.2.C:14: instantiated from here
egcs-bug.2.C:14: redefinition of `template <class XX> template <class X> class A<X>'
egcs-bug.2.C:9: `template <class XX> template <class X> class A<X>' previously declared here
egcs-bug.2.C:14: confused by earlier errors, bailing out
More information about the Gcc-bugs
mailing list