This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]