https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81275
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- To get rid of the warning just with -fsanitize=threads we could do: --- gcc/tree-eh.c.jj 2017-07-14 13:04:47.000000000 +0200 +++ gcc/tree-eh.c 2017-07-25 17:09:58.279461377 +0200 @@ -1598,7 +1598,8 @@ decide_copy_try_finally (int ndests, boo gimple *stmt = gsi_stmt (gsi); if (!is_gimple_debug (stmt) && !gimple_clobber_p (stmt) - && !gimple_call_builtin_p (stmt, BUILT_IN_STACK_RESTORE)) + && !gimple_call_builtin_p (stmt, BUILT_IN_STACK_RESTORE) + && !gimple_call_internal_p (stmt, IFN_TSAN_FUNC_EXIT)) return false; } return true; at the expense of (-O0) having more __tsan_func_exit calls but on the other side perhaps simpler code. But that doesn't solve the #c2 testcase where we'd warn anyway. The problem is that for: switch (a) <default: <D.2312>, case 0: <D.2310>> <D.2310>: switch (b) <default: <D.2311>> <D.2311>: D.2315 = 0; return D.2315; goto <D.2313>; <D.2312>: D.2315 = 0; return D.2315; <D.2313>: this ends with a label and thus gimple_seq_may_fallthru returns true, even when the only goto to that label is dead. I guess we need to improve switch expansion for these pathological cases.