This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


> 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}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]