This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH: Towards two-phase name lookup and other things...
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Phil Edwards <phil at jaj dot com>, Gerald Pfeifer <pfeifer at dbai dot tuwien dot ac dot at>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 17 Jan 2003 09:16:44 -0800
- Subject: Re: C++ PATCH: Towards two-phase name lookup and other things...
--On Thursday, January 16, 2003 10:57:40 PM -0500 Phil Edwards
<phil@jaj.com> wrote:
The library has to do lots of "this->" everywhere already to avoid Koenig
lookup. The last time I walked the library code looking for places where
we were forgetting to prefix with "this->", I admit this
only-with-templates rule completely slipped my mind.
BTW, a problem similar to Koenig lookup can occur here, as you probably
already know:
template <typename T> struct B { int i; };
int i;
template <typename T> struct D : public B<T> { void f() { i = 3; } };
Now, the last line is legal, but refers to the global i. So, the fact
that the parser now makes you write this-> may actually prevent some
pretty weird bugs in the library. (User declares a global variable,
then #include <iostream>, then wonders why the heck the global variable
is getting stomped on.)
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com