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: template member variable bug in gcc 3.4?


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}


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