[Bug c++/34870] argument-dependent lookup wronly finds friend declaration
dragan at plusplus dot co dot yu
gcc-bugzilla@gcc.gnu.org
Tue Dec 30 13:22:00 GMT 2008
------- Comment #5 from dragan at plusplus dot co dot yu 2008-12-30 13:20 -------
The standard says that the friend declaration should inject the name 'func'
into the enclosing namespace, but in a way that it can be found only by ADL.
Here is a test case without templates:
struct Foo
{
friend void func(const Foo &) {}
};
void check(const Foo & x)
{
func(x); <-- ADL, no error
::func(x); <-- not ADL, GCC issue an error
}
GCC handles this case correctly. The problem is it doesn't work
when templates come to play.
I personally find this behavior of great value. It reduces name clobbering.
I can for example do:
struct Foo {
template <typename Type>
friend bool is(const Foo & foo);
};
... and not clobber any namespace with a function of such non-unique name 'is'.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34870
More information about the Gcc-bugs
mailing list