This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/34870] argument-dependent lookup wronly finds friend declaration



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]