http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58714
Marc Glisse <glisse at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |NEW Last reconfirmed| |2013-10-13 CC| |glisse at gcc dot gnu.org Resolution|DUPLICATE |--- Ever confirmed|0 |1 --- Comment #3 from Marc Glisse <glisse at gcc dot gnu.org> --- The quoted paragraph is implemented in gcc-4.9. However, this still fails. The strange thing is that both of these versions work: static_cast<X&>(t ? a : b) = X{}; (t ? a : b) = static_cast<X&&>(X{}); There is special code in cp_build_modify_expr to handle assignment to a conditional, but it contains this line: rhs = stabilize_expr (rhs, &preeval); which apparently loses the prvalue-ness of rhs. I think we can consider it as a different issue from PR 53000, because operator?: worked ok, it is the later assignment which failed. By the way, this C++03 version: struct X { private: X& operator=(const X&); X& operator=(X& ); }; void f(bool t) { X a, b; *(t ? &a : &b) = X(); (t ? a : b) = X(); } says: c.cc: In function 'void f(bool)': c.cc:3:6: error: 'X& X::operator=(const X&)' is private X& operator=(const X&); ^ c.cc:9:18: error: within this context *(t ? &a : &b) = X(); ^ c.cc:4:6: error: 'X& X::operator=(X&)' is private X& operator=(X& ); ^ c.cc:10:15: error: within this context (t ? a : b) = X(); ^ c.cc:4:6: error: 'X& X::operator=(X&)' is private X& operator=(X& ); ^ c.cc:10:15: error: within this context (t ? a : b) = X(); ^ The fact that it tries to use X::operator=(X&) seems like a bug, which could easily be turned into wrong-code.