Common V3 coding bug
Nathan Myers
ncm@nospam.cantrip.org
Wed Jul 18 01:18:00 GMT 2001
On Tue, Jul 17, 2001 at 10:59:27PM -0700, Mark Mitchell wrote:
> There are a bunch of places in the code where V3 does:
>
> template <class T> struct A { int i; };
> template <class T> struct B : public A<T> {
> void f() { i = 3; }
> };
>
> This isn't valid C++; there's no `i' in scope in `B'. You have
> to add `using A<T>::i;' if you want to do this, or write `B<T>::i'.
The preferred fix is
> void f() { this->i = 3; }
If A<>::i were a type, it could still be mentioned without template
arguments, e.g.:
> void g() { int j = sizeof B::i; }
It would be nice if the compiler were to emit error messages the same way.
Nathan Myers
ncm at cantrip dot org
More information about the Libstdc++
mailing list