This is the mail archive of the gcc-patches@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]

Re: [PATCH] rvalue reference implementation for C++0x


On Sun, 2007-03-11 at 17:54 -0400, Jason Merrill wrote:
> struct A {};
> struct B {};
> struct C
> {
>   operator A();
>   operator B&();
> };
> 
> C c;
> 
> void f (A&&);
> void f (B&&);
> 
> int main()
> {
>    f (c);
> }

This case does seem to be handled correctly by the patch, it gives

        t.C: In function 'int main()':
        t.C:16: error: call of overloaded 'f(C&)' is ambiguous
        t.C:11: note: candidates are: void f(A&&)
        t.C:12: note:                 void f(B&&)

The place where it happens is inside convert_ics()  at
gcc/cp/call.c:5803.

      if (t1->cand->fn != t2->cand->fn)
	return 0;

This is the part of the code that attempts to compare two user-defined
conversion sequences. Since the standard only defines ordering on
user-defined conversion sequences "if they contain the same user-defined
conversion function or constructor" the example is ambiguous like you
say, but it is handled correctly with the patch. The patch compares
rvaluedness in the standard conversion sequences, but only after the
point in the code where the user-defined conversion sequences are found
to be indistinguishable.

-- 
-  Russell Yanofsky (PGP ID: 0x5FAA0216)
-  http://russ.yanofsky.org/
--

Attachment: signature.asc
Description: This is a digitally signed message part


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