]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/58714 (Bogus overload resolution for the assignment operator in assignment...
authorJason Merrill <jason@redhat.com>
Thu, 7 Aug 2014 19:50:04 +0000 (15:50 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 7 Aug 2014 19:50:04 +0000 (15:50 -0400)
PR c++/58714
* tree.c (stabilize_expr): A stabilized prvalue is an xvalue.

From-SVN: r213734

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/cpp0x/rv-cond1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/expr/cond12.C [new file with mode: 0644]

index 4b87bf50cc510e9c8273f5951deb3c2a8d7d2278..b0e1efd197322367d7a53b782b128a7655b74ebe 100644 (file)
@@ -1,3 +1,8 @@
+2014-08-07  Jason Merrill  <jason@redhat.com>
+
+       PR c++/58714
+       * tree.c (stabilize_expr): A stabilized prvalue is an xvalue.
+
 2014-01-27  Jason Merrill  <jason@redhat.com>
 
        PR c++/59823
index ed4bff6c5aa3aeb7a52e6bf50737179b3369f40f..a9ff1c16350628c9cf5929c2d385db0983fb5cb9 100644 (file)
@@ -3748,6 +3748,10 @@ stabilize_expr (tree exp, tree* initp)
     {
       init_expr = get_target_expr (exp);
       exp = TARGET_EXPR_SLOT (init_expr);
+      if (CLASS_TYPE_P (TREE_TYPE (exp)))
+       exp = move (exp);
+      else
+       exp = rvalue (exp);
     }
   else
     {
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-cond1.C b/gcc/testsuite/g++.dg/cpp0x/rv-cond1.C
new file mode 100644 (file)
index 0000000..a8f598f
--- /dev/null
@@ -0,0 +1,13 @@
+// PR c++/58714
+// { dg-do compile { target c++11 } }
+
+struct X {
+  X& operator=(const X&) = delete;
+  X& operator=(X&& ) = default;
+};
+
+void f(bool t) {
+  X a, b;
+  *(t ? &a : &b) = X();
+  (t ? a : b) = X();
+}
diff --git a/gcc/testsuite/g++.dg/expr/cond12.C b/gcc/testsuite/g++.dg/expr/cond12.C
new file mode 100644 (file)
index 0000000..9134f81
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/58714
+// { dg-do run }
+
+struct X {
+    X& operator=(const X&){}
+    X& operator=(X&){__builtin_abort();}
+};
+
+int main(int argv,char**) {
+  X a, b;
+  ((argv > 2) ? a : b) = X();
+}