diff mbox

C++ PATCH for c++/59296 (rvalue object and lvalue ref-qualifier)

Message ID 53A47D57.8070706@redhat.com
State New
Headers show

Commit Message

Jason Merrill June 20, 2014, 6:28 p.m. UTC
On 06/20/2014 03:11 PM, Jason Merrill wrote:
> On 06/19/2014 01:29 PM, Marc Glisse wrote:
>> That looks weird to me. The const&& version is a better match than the
>> const&, so we should pick that one in overload resolution, but if we
>> remove the const&& version, the other one seems valid to me
>
> Hmm, you're right, I was confused.

Here's a patch that fixes this properly.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit cc1e903c60c452ad7b618f6a9ff25ae85741424e
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jun 20 14:51:21 2014 +0200

    	PR c++/59296
    	* call.c (add_function_candidate): Avoid special 'this' handling
    	if we have a ref-qualifier.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index da91433..4847c3a 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -2025,9 +2025,9 @@  add_function_candidate (struct z_candidate **candidates,
 		     object parameter has reference type.  */
 		  bool rv = FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (fn));
 		  parmtype = cp_build_reference_type (parmtype, rv);
-		  /* Don't bind an rvalue to a const lvalue ref-qualifier.  */
-		  if (!rv)
-		    lflags |= LOOKUP_NO_RVAL_BIND|LOOKUP_NO_TEMP_BIND;
+		  /* The special handling of 'this' conversions in compare_ics
+		     does not apply if there is a ref-qualifier.  */
+		  is_this = false;
 		}
 	      else
 		{
@@ -8597,10 +8597,11 @@  compare_ics (conversion *ics1, conversion *ics2)
   /* [over.ics.rank]
 
      --S1 and S2 are reference bindings (_dcl.init.ref_) and neither refers
-     to an implicit object parameter, and either S1 binds an lvalue reference
-     to an lvalue and S2 binds an rvalue reference or S1 binds an rvalue
-     reference to an rvalue and S2 binds an lvalue reference
-     (C++0x draft standard, 13.3.3.2)
+     to an implicit object parameter of a non-static member function
+     declared without a ref-qualifier, and either S1 binds an lvalue
+     reference to an lvalue and S2 binds an rvalue reference or S1 binds an
+     rvalue reference to an rvalue and S2 binds an lvalue reference (C++0x
+     draft standard, 13.3.3.2)
 
      --S1 and S2 are reference bindings (_dcl.init.ref_), and the
      types to which the references refer are the same type except for