This is the mail archive of the gcc-patches@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: 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


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