This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: GCC 3.4.0: a derived class can't access the data member of a template base class
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: "Frank Chow" <fzhou at mtone dot com dot cn>
- Cc: "gcc-bugs at gcc dot gnu dot org" <gcc-bugs at gcc dot gnu dot org>
- Date: 21 Jun 2004 13:50:40 -0300
- Subject: Re: GCC 3.4.0: a derived class can't access the data member of a template base class
- Organization: Red Hat Global Engineering Services Compiler Team
- References: <SERVER05tX60LUDA1Xi00000d5a@server05.mtone.com.cn>
> 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}