This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Yet another template bug in gcc-2.95.1
> > In its context, the name in the template-id certainly refers to the
> > template.
>
> Thus, it introduces the name into the class scope, and, later on, it
> is overloaded with the member function. I don't think they should
> conflict.
If this was a pure declaration, I'd agree. However, it is a
specialization. As such, the name must refer to a template
(14.2/2). This involves name lookup of the template's name. Since this
name lookup returns the member when performed with the full class
definition, there is a conflict. What would you think about
template<class>void foo();
template<class>
class Bar{
void foo();
friend void foo<>();
};
Right or wrong? If right, which statement in the standard justifies
finding the global template and not the method? (BTW, g++ does
interesting things with this code: just try to use the friend
relationship). If wrong, what is the difference to the code in
question?
> Nope, you only have to provide a separate definition when a
> specialization is declared, which means it must start with `template
> <...>', and be in namespace scope. In the case of the friend
> declaration, it's just referring to a particular specialization, like
> explicitly specifying template members when doing a template function
> call.
Ok. I was assuming that 7.3.1.2/3 says that the friend declaration of
the specialization declares it in the nearest enclosing namespace
scope; but that is apparently not the case.
Regards,
Martin