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: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- To: Phil Edwards <phil at jaj dot com>
- Cc: Gerald Pfeifer <pfeifer at dbai dot tuwien dot ac dot at>, Mark Mitchell <mark at codesourcery dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 22 Jan 2003 12:11:07 +0100
- Subject: Re: C++ PATCH: Towards two-phase name lookup and other things...
> On Fri, Jan 17, 2003 at 02:33:09AM +0100, Gerald Pfeifer wrote:
> > On Thu, 16 Jan 2003, Mark Mitchell wrote:
> >
> > > (The standard library did a lot of:
> > >
> > > template <typename T> struct B { int i; };
> > > template <typename T> struct D : public B<T> { void f() { i = 3; } };
> > >
> > > which is not legal. You meant to say "this->i".)
> > >
> > > Y'all will probably make me add a helpful error message like the
> > > typename one for this case too.
> >
> > I have to admit I didn't now about the this-> thingie being required
>
> Without a helpful error message, this is definitely going to cause bug
> reports ("But it works with normal classes! Templates suck! Wah!"),
> and I don't really blame the users for doing so. In my experience, most
> C++ coders still don't know that specialization can declare a completely
> different structure than that declared by the primary template. (It's
> not exactly intuitive to do so, after all.)
>
> 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.
Here is a related testcase, which I assume should be OK (so it is
IMHO a parser bug) but on the other hand I also did not knew about
this C++ weirdness, so I might be wrong.... The following code does
not work, I believe the using should cure the need for the this->
or at least issue a warning...
template <typename T>
struct A {
int i;
};
template <typename T>
struct B: public A<T> {
using A<T>::i;
int f() const { return i; }
};
Should I submit a bug report.
With "gcc version 3.4 20030118 (experimental)", blitz is completely
broken because this construction is not working. Should I submit
a gcc bug report or correct blitz to introduce this-> everywhere ?
Thank's
--------------------------------------------------------------------
Theodore Papadopoulo
Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
--------------------------------------------------------------------