[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 Andrew Pinski changed: What|Removed |Added CC||rogero at howzatt dot co.uk --- Comment #13 from Andrew Pinski --- *** Bug 64181 has been marked as a duplicate of this bug. ***
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 Jason Merrill changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution|--- |FIXED Target Milestone|--- |8.4 --- Comment #12 from Jason Merrill --- Fixed for 8.4/9.2/10.
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 --- Comment #11 from Jason Merrill --- Author: jason Date: Fri Jul 19 11:53:41 2019 New Revision: 273601 URL: https://gcc.gnu.org/viewcvs?rev=273601=gcc=rev Log: PR c++/82081 - tail call optimization breaks noexcept If a noexcept function calls a function that might throw, doing the tail call optimization means that an exception thrown in the called function will propagate out, breaking the noexcept specification. So we need to prevent the optimization in that case. * tree-tailcall.c (find_tail_calls): Don't turn a call from a nothrow function to a might-throw function into a tail call. Added: branches/gcc-8-branch/gcc/testsuite/g++.dg/tree-ssa/tail-call-1.C Modified: branches/gcc-8-branch/gcc/ChangeLog branches/gcc-8-branch/gcc/tree-tailcall.c
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 --- Comment #10 from Jason Merrill --- Author: jason Date: Fri Jul 19 08:52:41 2019 New Revision: 273594 URL: https://gcc.gnu.org/viewcvs?rev=273594=gcc=rev Log: PR c++/82081 - tail call optimization breaks noexcept If a noexcept function calls a function that might throw, doing the tail call optimization means that an exception thrown in the called function will propagate out, breaking the noexcept specification. So we need to prevent the optimization in that case. * tree-tailcall.c (find_tail_calls): Don't turn a call from a nothrow function to a might-throw function into a tail call. Added: branches/gcc-9-branch/gcc/testsuite/g++.dg/tree-ssa/tail-call-1.C Modified: branches/gcc-9-branch/gcc/ChangeLog branches/gcc-9-branch/gcc/tree-tailcall.c
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 --- Comment #9 from Jason Merrill --- Author: jason Date: Mon Apr 29 17:27:13 2019 New Revision: 270656 URL: https://gcc.gnu.org/viewcvs?rev=270656=gcc=rev Log: PR c++/82081 - tail call optimization breaks noexcept If a noexcept function calls a function that might throw, doing the tail call optimization means that an exception thrown in the called function will propagate out, breaking the noexcept specification. So we need to prevent the optimization in that case. * tree-tailcall.c (find_tail_calls): Don't turn a call from a nothrow function to a might-throw function into a tail call. Added: trunk/gcc/testsuite/g++.dg/tree-ssa/tail-call-1.C Modified: trunk/gcc/ChangeLog trunk/gcc/tree-tailcall.c
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 --- Comment #8 from Jason Merrill --- Created attachment 46157 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46157=edit fix Here's a patch. I'm not sure if it will go into GCC 9 or 10.
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 Jason Merrill changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |jason at gcc dot gnu.org
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 Jason Merrill changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #7 from Jason Merrill --- (In reply to Thiago Macieira from comment #0) > 1) forbid tail-call optimisation of a noexcept(false) call in a noexcept > function, so that there is a frame in place for the unwinder to find. This seems like the necessary solution. Exception specifications should be enforced in the callee, and tail-call optimization is breaking that.
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 Jonathan Wakely changed: What|Removed |Added Status|RESOLVED|NEW Resolution|INVALID |--- --- Comment #6 from Jonathan Wakely --- I think the code is valid, and should terminate.
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 --- Comment #5 from Paweł Dziepak --- Is it really undefined? n4700 states in 18.4/5: Whenever an exception is thrown and the search for a handler (18.3) encounters the outermost block of a function with a non-throwing exception specification, the function std::terminate() is called (18.5.1).
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 Andrew Pinski changed: What|Removed |Added Status|WAITING |RESOLVED Resolution|--- |INVALID --- Comment #4 from Andrew Pinski --- Actually I was wrong. What changes in c++17 is throw () becomes the same as noexcept and no longer has the runtime catch. So is invalid and undefined at runtime.
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 Andrew Pinski changed: What|Removed |Added Status|UNCONFIRMED |WAITING Last reconfirmed||2017-10-26 Ever confirmed|0 |1 --- Comment #3 from Andrew Pinski --- C++11 until c++17 does not require the unwinding for except. This changed with c++17. Can you try with -std=c++17 (or -std=gnu++17)?
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 Andrew Pinski changed: What|Removed |Added CC||pdziepak at quarnos dot org --- Comment #2 from Andrew Pinski --- *** Bug 82741 has been marked as a duplicate of this bug. ***
[Bug c++/82081] Tail call optimisation of noexcept function leads to exception allowed through
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82081 --- Comment #1 from Andrew Pinski --- The C++ front-end should have wrapped noexcept_function's body with: try { ... } catch(..) { std::terminate(); } Like it does for throw() case.