[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 Marek Polacek changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED --- Comment #9 from Marek Polacek --- Fixed.
[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 --- Comment #8 from Marek Polacek --- Author: mpolacek Date: Fri Jun 29 15:25:14 2018 New Revision: 262254 URL: https://gcc.gnu.org/viewcvs?rev=262254=gcc=rev Log: PR c++/86184 * tree.c (cp_save_expr): Don't call save_expr for TARGET_EXPRs. * g++.dg/ext/cond3.C: New test. Added: trunk/gcc/testsuite/g++.dg/ext/cond3.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/tree.c trunk/gcc/testsuite/ChangeLog
[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 Eric Gallager changed: What|Removed |Added Keywords||patch CC||egallager at gcc dot gnu.org --- Comment #7 from Eric Gallager --- (In reply to Marek Polacek from comment #6) > https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01345.html adding "patch" keyword
[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 --- Comment #6 from Marek Polacek --- https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01345.html
[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 --- Comment #5 from Marek Polacek --- Runtime test: int j; struct X { X() { j++; } operator bool() { return true; } }; /* Only create X once. */ bool b = X() ?: false; bool b2 = X() ? X() : false; int main () { if (j != 3) __builtin_abort (); }
[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 Marek Polacek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
[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 Marek Polacek changed: What|Removed |Added CC||mpolacek at gcc dot gnu.org --- Comment #4 from Marek Polacek --- It looks like we should avoid wrapping a TARGET_EXPR in SAVE_EXPR: 4806 /* Make sure that lvalues remain lvalues. See g++.oliva/ext1.C. */ 4807 if (lvalue_p (arg1)) 4808 arg2 = arg1 = cp_stabilize_reference (arg1); 4809 else 4810 arg2 = arg1 = cp_save_expr (arg1); because that makes the clk_class expression a clk_none.
[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 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 --- 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.