C++ parser issue [templ.res]
Jan Van Dijk
janvandijkinjapan@yahoo.co.jp
Tue Jan 28 12:48:00 GMT 2003
Hi,
In spite of reading all of 14.6 [temp.res] repeatedly, I am still
in doubt whether the new parser correctly deals with the code
below or not. Since a week or two gcc-head refuses to compile D<T>::bad(),
gcctest.cpp: In member function `void D<T>::bad()':
gcctest.cpp:12: error: `i' has not been declared
Qualifying i as B<T>::i (thus making i a dependent name explicitly)
fixes the problem, see ugly(). To my surprise, look up of member
variables is now different from that of member functions: f() does
not need to be qualified (see good()). Either I missed a crucial
section of the standard (which one?), or this is a parser bug.
I checked gcc/cp/NEWS and other sources to see an announcement of this
change (making it intentional), but did not recognize anything relevant.
Thanks for your time,
Regards, Jan van Dijk
template <class T>
struct B
{
int i;
int f();
};
template <class T>
struct D : public B<T>
{
void good(){ f(); } // no B<T>:: required
void bad(){ i=0; } // does not compile with `head',
void ugly(){ B<T>::i=0; } // ... this does.
};
--
Keio-Tsuushin Residence
Jan van Dijk, Room 210
2 Chome 19-30, Mita Minato-ku
108 Tokyo, Japan
jan@etpmod.phys.tue.nl
tel: +81 3 5476 9461 (home)
__________________________________________________
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/
More information about the Gcc
mailing list