This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: what is wrong here?
> IMHO, the using declaration causes the name `f' to be found in N, so
> the friend declaration shouldn't introduce a new declaration, just
> bind to the one it finds.
This should be one of these comp.std.c++ things, which I continue to
discuss on egcs-bugs, violating the netiquette :-)
According to 7.3.1.2, [namespace.memdef]/3, the friend declaration
introduces a new declaration if that is the 'first declaration'. Now,
does the using-declaration introduce f(void) as a member of N? 7.3.3,
[namespace.udecl]/2 would make us think so.
However, if that was the case: Why is it allowed that two using
declarations introduce two functions with identical parameter lists?
(see Note in [namespace.udecl]/11)? Clearly, if the functions *where*
declared in the namespace that contains the using declaration, it
would violate the odr: a function would have two definitions.
Also, according to 11.4, [class.friend]/5, a friend can be defined in
the class. Do you think that the following is well-formed?
namespace X{
void foo();
}
namespace Y{
using X::foo;
class Bar{
friend void foo(){}
};
}
Following your line of reasoning, this should define X::foo. I hope
this is not the case, though.
Regards,
Martin