This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/34870] argument-dependent lookup wronly finds friend declaration
- From: "dragan at plusplus dot co dot yu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Dec 2008 13:21:00 -0000
- Subject: [Bug c++/34870] argument-dependent lookup wronly finds friend declaration
- References: <bug-34870-15652@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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