GCC 3.4.0: a derived class can't access the data member of a template base class

Alexandre Oliva aoliva@redhat.com
Mon Jun 21 16:50:00 GMT 2004


> template <typename T> struct D : public T { D() { nSize = sizeof(T);
> } };


nSize is not a template-dependent name, so it's bound at parse time,
rather than at template instantiation time.  You must use this->nSize
or T::nSize to make it template-dependent.

> By the way, gcc (GCC) 3.3.1 (cygwin version) can compile this code
> successfully

That was a bug, fixed in 3.4.

> so do Visual C++ .Net (cl v 13.10.3077).

You'll have to report this bug to someone else, then :-)

-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}



More information about the Gcc-bugs mailing list