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

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Maybe (untested):

--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -1703,8 +1703,8 @@ lower_try_finally (struct leh_state *state, gtry *tp)
   ndests += this_tf.may_return;
   ndests += this_tf.may_throw;

-  /* If the FINALLY block is not reachable, dike it out.  */
-  if (ndests == 0)
+  /* If the FINALLY block is not reachable or empty, dike it out.  */
+  if (ndests == 0 || gimple_seq_empty_p (gimple_try_cleanup (tp)))
     {
       gimple_seq_add_seq (&this_tf.top_p_seq, gimple_try_eval (tp));
       gimple_try_set_cleanup (tp, NULL);

Reply via email to