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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=97720

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Mathias Stearn from comment #3)
> This is related to https://wg21.link/CWG2219

Indeed.  The problem is that the compiler is optimizing away the catch block
because it's unreachable, but then the throw can't find a handler for int and
so calls std::terminate without unwinding (under
https://eel.is/c++draft/except#terminate-2 "In the situation where no matching
handler is found, it is implementation-defined whether or not the stack is
unwound before std​::​terminate is invoked.")

Since that doesn't actually apply here, it seems like we need to keep something
in the call site table to indicate that there is a handler, so unwinding needs
to happen.  We could change the action table entry to be catch (...) to avoid
emitting the type_info reference and omit any actual code for it in the landing
pad, but we can't actually remove the region.

What I'm describing is option 3 in the CWG2219 writeup. I am skeptical that it
would have the level of impact that the submitter describes, I think
pass_cleanup_eh just needs to be able to keep/mark a dead region in some cases
so it only affects the action table, not the CFG.

PR97720 is another case where we're leaving out a needed action table entry,
but it's a different kind of entry (for noexcept) and it is reachable, so the
fixes may not overlap all that much.

Reply via email to