public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106057] New: Missed stmt_can_throw_external check in stmt_kills_ref_p Date: Wed, 22 Jun 2022 16:26:28 +0000 [thread overview] Message-ID: <bug-106057-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106057 Bug ID: 106057 Summary: Missed stmt_can_throw_external check in stmt_kills_ref_p Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- int a; int b; __attribute__((const)) int maybethrow() { if (!b) throw(0); return 0; } void test() { a=1; a=maybethrow(); a=0; } int main() { try { test(); } catch(int) { if (!a) __builtin_abort (); } return 0; } aborts when built with -O2 while I think it should not. The bug is that a=maybethrow() is considered a kill which it is not since exception happens earlier. I think we need: diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc index b1e7a2d5afc..7307e386f96 100644 --- a/gcc/tree-ssa-alias.cc +++ b/gcc/tree-ssa-alias.cc @@ -3337,7 +3338,9 @@ stmt_kills_ref_p (gimple *stmt, ao_ref *ref) ??? We only need to care about the RHS throwing. For aggregate assignments or similar calls and non-call exceptions the LHS might throw as well. */ - && !stmt_can_throw_internal (cfun, stmt)) + && !stmt_can_throw_internal (cfun, stmt) + && (!stmt_can_throw_external (cfun, stmt) + || !ref_may_alias_global_p (ref, false))) { tree lhs = gimple_get_lhs (stmt); /* If LHS is literally a base of the access we are done. */
next reply other threads:[~2022-06-22 16:26 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-22 16:26 hubicka at gcc dot gnu.org [this message] 2022-06-22 16:51 ` [Bug c++/106057] " hubicka at gcc dot gnu.org 2022-06-23 9:34 ` hubicka at gcc dot gnu.org 2022-06-24 11:54 ` cvs-commit at gcc dot gnu.org 2022-08-12 14:26 ` cvs-commit at gcc dot gnu.org 2023-04-27 13:18 ` cvs-commit at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-106057-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).