template member variable bug in gcc 3.4?
Alexandre Oliva
aoliva@redhat.com
Wed Apr 21 19:33:00 GMT 2004
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}
More information about the Gcc-bugs
mailing list