[Bug c++/58714] New: Bogus value category in ternary operator?

ali.baharev at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Oct 13 12:39:00 GMT 2013


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


More information about the Gcc-bugs mailing list