------- 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