This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: template member variable bug in gcc 3.4?
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: "Dyer, Christopher" <cdyer at amazon dot com>
- Cc: <gcc-bugs at gcc dot gnu dot org>
- Date: 21 Apr 2004 16:17:25 -0300
- Subject: Re: template member variable bug in gcc 3.4?
- Organization: Red Hat Global Engineering Services Compiler Team
- References: <DDAF11B1DB39054FA0CF6DFA6D3E595D044C721C@ex-mail-sea-02.ant.amazon.com>
On Apr 20, 2004, "Dyer, Christopher" <cdyer@amazon.com> wrote:
> // the following line compiles in GCC 3.2, but not in GCC 3.4.
> int position() const { return t_->position(); };
> // to make it work, it must be changed to one of the following
> // (compiles in both GCC 3.2 and 3.4)
> // int position() const { return driver<T>::t_->position(); };
> // int position() const { return this->t_->position(); };
t_ is not a template-dependent name, so it is supposed to bind at
parse time, not at template instantiation time. However, since
there's no declaration for t_ visible at that point, the compiler
rightfully reports an error. Older versions of GCC used to defer
binding to template instantiation time, which was incorrect.
By using this->t_ or driver<T>::t_, you make t_ template-dependent, so
the name is only resolved at template instantiation time.
--
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}