Commit fc2bfea1 by Jason Merrill Committed by Jason Merrill

re PR c++/58714 (Bogus overload resolution for the assignment operator in…

re PR c++/58714 (Bogus overload resolution for the assignment operator in assignment to a conditional)

	PR c++/58714
	* tree.c (stabilize_expr): A stabilized prvalue is an xvalue.

From-SVN: r210283
parent 5f901ccf
2014-05-09 Jason Merrill <jason@redhat.com>
PR c++/58714
* tree.c (stabilize_expr): A stabilized prvalue is an xvalue.
PR c++/54348
* call.c (build_conditional_expr_1): If overload resolution finds
no match, just say "different types".
......
......@@ -3785,6 +3785,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
{
......
// 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();
}
// 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();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment