[PATCH] Fix PR c++/59366 A friend function template defined in a class is found without ADL
Momchil Velikov
momchil.velikov@gmail.com
Mon May 5 10:07:00 GMT 2014
Hello,
A friend function, defined in a class and not declared outside should
be hidden from ordinary name lookup and only found by argument-dependent
lookup, like:
struct S
{
friend void f() {}
friend void g(const S &) {}
};
int
main()
{
f(); // error
g(S()); // correct, found by ADL
}
GCC correctly handles this case, but fails for function templates like:
struct S
{
template<typename T> friend void f(T) {}
};
int
main()
{
f(1); // should be an error, GCC succeeds
f(S()); // correct, found by ADL
}
~chill
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hidden-friend-template.diff
Type: text/x-patch
Size: 3258 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140505/65c1d161/attachment.bin>
More information about the Gcc-patches
mailing list