Problem with nested classes and templates
Wolfgang Bangerth
wolf@gaia.iwr.uni-heidelberg.de
Thu Nov 5 22:00:00 GMT 1998
Hi there,
When working with egcs 1.1b, I noticed the following
problem. Given this program:
-------------------------------------------------------
template <int rank, int dim> class Outer;
template <int dim>
class Outer<1,dim> {
public:
Outer ();
class Inner {
public:
Inner (){};
};
};
template <int dim>
Outer<1,dim>::Outer () {
Inner a;
};
Outer<1,3> o;
--------------------------------------------------------
egcs says to me:
a.cc: In instantiation of `Outer<1,3>::Inner::Inner<1>()':
a.cc:18: instantiated from `Outer<1,3>::Outer<3>()'
a.cc:23: instantiated from here
a.cc:11: new declaration `Outer<1,1>::Inner::Inner<>()'
a.cc:11: ambiguates old declaration `Outer<1,3>::Inner::Inner<1>()'
Apart from the fact that I do not understand what it's all about,
it looks strange that in the two last lines
Outer<1,1>:: ... <>
and
Outer<1,3>:: ... <1>
are compared.
Anyway, egcs is great and many thanks go to you for your efforts!
-- Wolfgang
-------------------------------------------------------------------
wolf@nike$ c++ -v -c a.cc
Reading specs from /usr/local/gcc/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
/usr/local/gcc/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=91 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__s
parc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) a.cc /var/tmp/ccvaOh7F.ii
GNU CPP version egcs-2.91.57 19980901 (egcs-1.1 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc/egcs-1.1b/include/g++
/usr/local/include
/usr/local/gcc/egcs-1.1b/sparc-sun-solaris2.6/include
/usr/local/gcc/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/include
/usr/include
End of search list.
/usr/local/gcc/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.57/cc1plus /var/tmp/ccvaOh7F.ii -quiet -dumpbase a.cc -version -o /var/tmp/ccA63BRe.s
GNU C++ version egcs-2.91.57 19980901 (egcs-1.1 release) (sparc-sun-solaris2.6) compiled by GNU C version egcs-2.91.57 19980901 (egcs-1.1 release).
More information about the Gcc-bugs
mailing list