Listing 1 compiles fine: class smallclass { public: int uu; smallclass(void) : uu(1) { } };
class largeclass : public smallclass { public: int *uup; void test(void) { uup = &(smallclass::uu); } }; int main () { largeclass a; a.test(); } Listing 2 fails: template <class E> class smallclass { public: E uu; smallclass(void) : uu(1) { } }; // class smallclass template <class E> class largeclass : public smallclass<E> { public: E *uup; void test(void) { uup = &(uu); } }; int main () { largeclass<int> a; a.test(); } The error on compile on both gcc-4.0.1 and 3.4.1 is: 'uu' was not declared in this scope or `uu' undeclared If one tries to fix it like this: void test(void) { uup = &(smallclass<E>::uu); } the error on both gcc-4.0.1 and 3.4.1 becomes: error: cannot convert 'int smallclass<int>::*' to 'int*' in assignment All code compiles fine on: - Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86 (Visual Studio 2005) - cxx (v6.5 su Tru64/alpha) - aCC (vA.5.55 per HP-UX/Itanium) - intel cc 9.0 - gcc 3.2 and 3.3 - Comeau C++ 4.3.3 -- Summary: template class derived from template class does not access base class' members Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: paolo dot greppi at tiscali dot it GCC build triplet: i686-pc-cygwin GCC host triplet: i686-pc-cygwin GCC target triplet: i686-pc-cygwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30657