This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Better document two-stage name lookup & template base classes,take 2
On Mon, 2003-07-21 at 17:24, Wolfgang Bangerth wrote:
>
> This is take 2, somehow incorporating Gerald's and Jason's suggestions. Mark,
> can I ask you again these two questions:
>
> > is the description of what -fpermissive does in this case
> > accurate? I should state that I'm not quite happy with what -fpermissive
> > presently does, since it only addresses the case of unqualified _function_
> > name lookup, but the respective case for variables is not covered. That
> > seems rather inconsistent.
I think the description is accurate. I agree with you that it would be
better to have -fpermissive treat variables as it does functions. (That
wasn't so practical until some of the recent clean-ups; now I think it
could be implemented without too much trouble.)
> > in the section above what is changed in the patch, we state
> > This distinction between lookup of dependent and non-dependent names is
> > called two-stage (or dependent) name lookup. G++ implements some
> > features of it since version 3.4 and is moving towards full compliance
> > with the standard.
> > I have the impression that we try to do it _all_ right already now. Should
> > this be reworded thus?
I *think* so.
I hadn't thought that we would get this case:
int f(int) { return 1; }
template <typename T> int g(T) { return f('a'); }
int f(char) { return 2; }
int main () {
return g(3);
}
right, but it turns out that my implementation of this stuff gets this
case right automatically. (The point is that "f('a')" should call
"f(int)", not "f(char)".)
void f(int);
template <typename T> void g(T) { f('a'); }
void f(char);
template void g(double);
will, I think, result in a call to "f(char)", not "f(int)". I hope to
fix this at some point in the relatively near future, but it's somewhat
tricky.
> ! Note that some compilers get these examples wrong and accept above code
> ! without an error. However, this is spurious, since they just don't
> ! implement two-stage name lookup correctly. This includes G++ versions
> ! prior to 3.4.
This paragraph, which I know you didn't write, isn't as tight as it
could be. How about:
Note that some compilers (including G++ versions prior to 3.4) get
these examples wrong and accept above code without an error. Those
compilers do not implement two-stage name lookup correctly.
Patch approved with that change; thank you!
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com