[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 Andrew Pinski changed: What|Removed |Added CC||kaballo86 at hotmail dot com --- Comment #18 from Andrew Pinski --- *** Bug 61736 has been marked as a duplicate of this bug. ***
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 Andrew Pinski changed: What|Removed |Added CC||zhonghao at pku dot org.cn --- Comment #17 from Andrew Pinski --- *** Bug 86475 has been marked as a duplicate of this bug. ***
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 Jason Merrill changed: What|Removed |Added Status|ASSIGNED|RESOLVED Known to work|9.0 | Resolution|--- |FIXED Target Milestone|--- |10.0 --- Comment #16 from Jason Merrill --- Fixed properly for GCC 10.
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 --- Comment #15 from Jason Merrill --- Author: jason Date: Sat Aug 17 01:34:00 2019 New Revision: 274597 URL: https://gcc.gnu.org/viewcvs?rev=274597=gcc=rev Log: PR c++/90393 - ICE with throw in ?: I fixed the DR 1560 implementation properly for GCC 10, but for GCC 9 feel that it's better not to change the meaning of well-formed code. Reverting the incomplete implementation fixes the ICEs. * call.c (build_conditional_expr_1): Revert changes from PR c++/64372 and c++/86205. Added: branches/gcc-9-branch/gcc/testsuite/g++.dg/expr/cond15.C branches/gcc-9-branch/gcc/testsuite/g++.dg/expr/cond16.C Removed: branches/gcc-9-branch/gcc/testsuite/g++.dg/cpp1y/dr1560.C Modified: branches/gcc-9-branch/gcc/cp/ChangeLog branches/gcc-9-branch/gcc/cp/call.c
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 --- Comment #14 from Jason Merrill --- Author: jason Date: Thu Aug 15 21:55:19 2019 New Revision: 274550 URL: https://gcc.gnu.org/viewcvs?rev=274550=gcc=rev Log: PR c++/90393 - ICE with thow in ?: My previous patch for 64372 was incomplete: it only stopped making the non-throw argument into an rvalue, lvalue_kind still considered the ?: expression to be an rvalue, leaving us worse than before. PR c++/64372, DR 1560 - Gratuitous lvalue-to-rvalue conversion in ?: * tree.c (lvalue_kind): Handle throw in one arm. * typeck.c (rationalize_conditional_expr): Likewise. (cp_build_modify_expr): Likewise. Added: trunk/gcc/testsuite/g++.dg/expr/cond15.C trunk/gcc/testsuite/g++.dg/expr/cond16.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/tree.c trunk/gcc/cp/typeck.c trunk/gcc/testsuite/g++.dg/abi/mangle53.C trunk/gcc/testsuite/g++.old-deja/g++.eh/cond1.C trunk/gcc/testsuite/g++.old-deja/g++.other/cond5.C
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 Justin Bassett changed: What|Removed |Added CC||jbassett271 at gmail dot com --- Comment #13 from Justin Bassett --- Reconfirmed with GCC 9.1, from this Stack Overflow question: https://stackoverflow.com/questions/57315054/unable-to-use-ternary-operator-to-conditionally-assign-istream/57315456 Some variants: https://godbolt.org/z/gcnglB (GCC 9.1) class Foo { public: Foo(int& i) : i{i > 0 ? i : throw "invalid"} {} private: int& i; }; Error: : In constructor 'Foo::Foo(int&)': :6:40: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int' 6 | : i{i > 0 ? i : throw "invalid"} |^ This one changed from GCC 8.3 and GCC 9.1, which I'm guessing is due to the work by Jason Merrill: https://godbolt.org/z/DfKGg4 struct no_copy { no_copy(no_copy const&) = delete; bool valid() const; }; class Foo { public: Foo(no_copy& it) : it{it.valid() ? it : throw "invalid"} {} private: no_copy& it; }; GCC 9.1: : In constructor 'Foo::Foo(no_copy&)': :11:47: error: cannot bind non-const lvalue reference of type 'no_copy&' to an rvalue of type 'no_copy' 11 | : it{it.valid() ? it : throw "invalid"} | ^ GCC 8.3: : In constructor 'Foo::Foo(no_copy&)': :11:38: error: use of deleted function 'no_copy::no_copy(const no_copy&)' : it{it.valid() ? it : throw "invalid"} ^ :2:5: note: declared here no_copy(no_copy const&) = delete; ^~~ :11:47: error: invalid initialization of non-const reference of type 'no_copy&' from an rvalue of type '' : it{it.valid() ? it : throw "invalid"} ^
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 Jonathan Wakely changed: What|Removed |Added Last reconfirmed|2016-11-23 00:00:00 |2019-1-2 --- Comment #12 from Jonathan Wakely --- (In reply to Jason Merrill from comment #10) > Author: jason > Date: Tue May 15 21:56:29 2018 > New Revision: 260272 > > URL: https://gcc.gnu.org/viewcvs?rev=260272=gcc=rev > Log: > PR c++/64372 - CWG 1560, gratuitous lvalue-rvalue conversion in ?: > > * call.c (build_conditional_expr_1): Don't force_rvalue when one arm > is a throw-expression. > > Added: > trunk/gcc/testsuite/g++.dg/cpp1y/dr1560.C > Modified: > trunk/gcc/cp/ChangeLog > trunk/gcc/cp/call.c Jason, you added known to work = 9.0 but neither comment 0 nor comment 8 is fixed by this patch. Comment 11 might be a different issue, or might be the same and has a misleading diagnostic (there's no & operator in the code), but either way it also isn't fixed.
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 --- Comment #11 from Shafik Yaghmour --- Bumping, it has been a while. I ran into this reviewing [diff.cpp11.expr] https://timsong-cpp.github.io/cppwp/n4659/diff.cpp11.expr and noticed the code in the example similar to the reduced sample fails to compile with current gcc trunk godbolt: https://godbolt.org/z/Ihm9Ps
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 --- Comment #10 from Jason Merrill --- Author: jason Date: Tue May 15 21:56:29 2018 New Revision: 260272 URL: https://gcc.gnu.org/viewcvs?rev=260272=gcc=rev Log: PR c++/64372 - CWG 1560, gratuitous lvalue-rvalue conversion in ?: * call.c (build_conditional_expr_1): Don't force_rvalue when one arm is a throw-expression. Added: trunk/gcc/testsuite/g++.dg/cpp1y/dr1560.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/call.c
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 Jason Merrill changed: What|Removed |Added Status|NEW |ASSIGNED CC||jason at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 Eric Fiselier changed: What|Removed |Added CC||eric at efcs dot ca --- Comment #9 from Eric Fiselier --- Bump. This should get fixed as it's not just wrong-code but also accepts-invalid and rejects-valid. The relevant wording from the standard: C++1z [expr.cond]p2: > (2) If either the second or the third operand has type void, > one of the following shall hold: > (2.1) The second or the third operand (but not both) is a > (possibly parenthesized) throw-expression (5.17); the result > is of the type and value category of the other.
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 hs changed: What|Removed |Added CC||hs at xmission dot com --- Comment #8 from hs --- I wanted to bump this bug and supply a simpler test-case: void blah(int&) {} int main() { int i{}; blah(true ? i : throw); } result with gcc 6.0: prog.cc: In function 'int main()': prog.cc:6:15: error: invalid initialization of non-const reference of type 'int&' from an rvalue of type 'int' blah(true ? i : throw 0); ~^ prog.cc:2:6: note: initializing argument 1 of 'void blah(int&)' void blah(int&) {} ^~~~
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 --- Comment #7 from Harald van Dijk harald at gigawatt dot nl --- (In reply to Manuel López-Ibáñez from comment #6) Even that is probably too much right now. :) I do hope to be able to make some bigger contributions in the future (in code too), and I really appreciate your comment.
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 Manuel López-Ibáñez manu at gcc dot gnu.org changed: What|Removed |Added Keywords||diagnostic, wrong-code Status|UNCONFIRMED |NEW URL||http://www.open-std.org/jtc ||1/sc22/wg21/docs/cwg_defect ||s.html#1560 Last reconfirmed||2014-12-22 Summary|Spurious warning with throw |[DR1560] Gratuitous |in ternary operator |lvalue-to-rvalue conversion |returning const reference |in conditional-expression ||with throw-expression ||operand Ever confirmed|0 |1 --- Comment #5 from Manuel López-Ibáñez manu at gcc dot gnu.org --- Thanks Harald! I updated the PR accordingly.
[Bug c++/64372] [DR1560] Gratuitous lvalue-to-rvalue conversion in conditional-expression with throw-expression operand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64372 --- Comment #6 from Manuel López-Ibáñez manu at gcc dot gnu.org --- BTW Harald, GCC needs more C++ FE developers, have you considered joining the project? Even if you don't end up contributing much code, you can get a gcc.gnu.org account for Bugzilla with the possibility of updating/confirming/rejecting bug reports.