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++/86184] Conditional expression with omitted operand cannot use rvalue of type convertible to bool


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86184

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|WAITING                     |NEW
            Summary|Shall gcc support this      |Conditional expression with
                   |feature?                    |omitted operand cannot use
                   |                            |rvalue of type convertible
                   |                            |to bool

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:

struct X {
  operator bool() { return true; }
};

X x;
X y = X() ? X() : x;
X z = X() ? : y;


tern.cc:7:15: error: lvalue required as unary ‘&’ operand
 X z = X() ? : y;
               ^
tern.cc:7:7: error: could not convert ‘X()’ from ‘X’ to ‘bool’
 X z = X() ? : y;
       ^~~


The manual says the conditional expression with the omitted operand should
"perfectly equivalent" to the first one.

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