[ Redirected from gcc-patches@ to gcc@ ]

Mark Mitchell <[EMAIL PROTECTED]> writes:

> This case is particularly tricky because of the fact that accepting
> the invalid code also means that we'll change the meaning of some
> valid code.  For example, in:
> 
> int f(int) {
>    return 1;
> }
> 
> struct S {
>    friend int f(char) { return 2; }
> };
> 
> int main () {
>    return f('a');
> }
> 
> we current return 2 from "main", which is incorrect.  (Does your patch
> fix this, by the way?  I'm not sure if we ever had the situation of an
> overload set in which some, but not all, functions were
> DECL_ANTICIPATED.)

Now that my patch handles the above case correctly, the test
g++.dg/template/friend10.C fails.  And the original test case in PR
5116 fails.

I think the issue here is whether we should prefer an explicitly
declared conversion operator over a friend function found using
argument dependent lookup.  With my current patch, we prefer the
conversion operator.  (When friends are injected, we prefer the friend
function, which seems straightforward and correct.)

Can somebody with more C++-fu than I have take a look at these two
cases and see what is correct?  Thanks.

Ian

Reply via email to