This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/86184] Conditional expression with omitted operand cannot use rvalue of type convertible to bool
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 20 Jun 2018 14:34:53 +0000
- Subject: [Bug c++/86184] Conditional expression with omitted operand cannot use rvalue of type convertible to bool
- Auto-submitted: auto-generated
- References: <bug-86184-4@http.gcc.gnu.org/bugzilla/>
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.