This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
template <class T> class Foo : public T::XXX {...}; legal?
- To: egcs-bugs at cygnus dot com
- Subject: template <class T> class Foo : public T::XXX {...}; legal?
- From: Christian Millour <chris at etca dot fr>
- Date: Tue, 23 Sep 1997 15:36:41 +0200 (MET DST)
Hi. The following used to work with gcc-2.7.2 but doesn't compile with
egcs-970917. Is it a problem with the new template stuff or is the
code below downright illegal ?
TIA.
xxxxxxx> cat temp1.cc
class Base {
public:
class Bar { public: virtual ~Bar() {}; };
};
class Derived : public Base {
public:
class Bar : public Base::Bar {};
};
template <class T>
class XYZ : public T::Bar {
};
void test() {
XYZ<Base> b;
XYZ<Derived> d;
}
xxxxxxx> g++ -Wall -pedantic -c temp1.cc
xxxxxxx> e++ -Wall -pedantic -c temp1.cc
temp1.cc:12: parse error before `{'
temp1.cc:12: syntax error before `{'
temp1.cc: In function `void test()':
temp1.cc:16: aggregate `class XYZ<Base> b' has incomplete type and cannot be initialized
temp1.cc:17: aggregate `class XYZ<Derived> d' has incomplete type and cannot be initialized
temp1.cc:17: warning: unused variable `{error} d'
temp1.cc:16: warning: unused variable `{error} b'
xxxxxxx> g++ -v -Wall -pedantic -c temp1.cc
gcc -v -Wall -pedantic -c temp1.cc
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/specs
gcc version 2.7.2
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=7 -Dsun -Dsparc -Dunix -D__svr4__ -D__SVR4 -D__GCC_NEW_VARARGS__ -D__sun__ -D__sparc__ -D__unix__ -D__svr4__ -D__SVR4 -D__GCC_NEW_VARARGS__ -D__sun -D__sparc -D__unix -Asystem(unix) -Asystem(svr4) -Acpu(sparc) -Amachine(sparc) -Wall -pedantic temp1.cc /var/tmp/cca004jd.ii
GNU CPP version 2.7.2 (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/g++-include
/usr/local/include
/usr/local/sparc-sun-solaris2.5/include
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/include
/usr/include
End of search list.
/usr/local/lib/gcc-lib/sparc-sun-solaris2.5/2.7.2/cc1plus /var/tmp/cca004jd.ii -quiet -dumpbase temp1.cc -Wall -pedantic -version -o /var/tmp/cca004jd.s
GNU C++ version 2.7.2 (sparc) compiled by GNU C version 2.7.2.
/usr/ccs/bin/as -V -Qy -s -o temp1.o /var/tmp/cca004jd.s
/usr/ccs/bin/as: SC4.2 dev 30 Nov 1995
xxxxxxx> e++ -v -Wall -pedantic -c temp1.cc
Reading specs from /home/cepia/cmillour/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.08/specs
gcc version egcs-2.90.08 970917 (gcc2-970802 experimental)
/home/cepia/cmillour/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.08/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Dsun -Dsparc -Dunix -D__svr4__ -D__SVR4 -D__GCC_NEW_VARARGS__ -D__sun__ -D__sparc__ -D__unix__ -D__svr4__ -D__SVR4 -D__GCC_NEW_VARARGS__ -D__sun -D__sparc -D__unix -Asystem(unix) -Asystem(svr4) -Acpu(sparc) -Amachine(sparc) -D__EXCEPTIONS -Wall -pedantic temp1.cc /var/tmp/cca004jh.ii
GNU CPP version egcs-2.90.08 970917 (gcc2-970802 experimental) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/home/cepia/cmillour/egcs/include/g++
/usr/local/include
/home/cepia/cmillour/egcs/sparc-sun-solaris2.5.1/include
/home/cepia/cmillour/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.08/include
/usr/include
End of search list.
/home/cepia/cmillour/egcs/lib/gcc-lib/sparc-sun-solaris2.5.1/egcs-2.90.08/cc1plus /var/tmp/cca004jh.ii -quiet -dumpbase temp1.cc -Wall -pedantic -version -o /var/tmp/cca004jh.s
GNU C++ version egcs-2.90.08 970917 (gcc2-970802 experimental) (sparc-sun-solaris2.5.1) compiled by GNU C version egcs-2.90.08 970917 (gcc2-970802 experimental).
temp1.cc:12: parse error before `{'
temp1.cc:12: syntax error before `{'
temp1.cc: In function `void test()':
temp1.cc:16: aggregate `class XYZ<Base> b' has incomplete type and cannot be initialized
temp1.cc:17: aggregate `class XYZ<Derived> d' has incomplete type and cannot be initialized
temp1.cc:17: warning: unused variable `{error} d'
temp1.cc:16: warning: unused variable `{error} b'
xxxxxxx>