This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/58714] New: Bogus value category in ternary operator?
- From: "ali.baharev at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 13 Oct 2013 12:39:26 +0000
- Subject: [Bug c++/58714] New: Bogus value category in ternary operator?
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58714
Bug ID: 58714
Summary: Bogus value category in ternary operator?
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ali.baharev at gmail dot com
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();
}
-----
The line:
(t ? a : b) = X();
gives:
error: use of deleted function âX& X::operator=(const X&)â
The code compiles with clang++ 3.4.
The sections in the Standard relevant here are: [expr.cond]/4 "If the second
and third operands [of the conditional operator] are glvalues of the same value
category and have the same type, the result is of that type and value category"
(text in brackets inserted for clarity).
This code was posted at stackoverflow.com/q/19341908/341970