public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-7605] analyzer: fix ICE with -fanalyzer-transitivity [PR104863] Date: Thu, 10 Mar 2022 21:53:12 +0000 (GMT) [thread overview] Message-ID: <20220310215312.094783858D39@sourceware.org> (raw) https://gcc.gnu.org/g:d016dd7dbb8140f03cde7e2179ebaf9ec3e9d2f1 commit r12-7605-gd016dd7dbb8140f03cde7e2179ebaf9ec3e9d2f1 Author: David Malcolm <dmalcolm@redhat.com> Date: Thu Mar 10 16:52:01 2022 -0500 analyzer: fix ICE with -fanalyzer-transitivity [PR104863] gcc/analyzer/ChangeLog: PR analyzer/104863 * constraint-manager.cc (constraint_manager::add_constraint): Refresh the EC IDs when adding constraints implied by offsets. gcc/testsuite/ChangeLog: PR analyzer/104863 * gcc.dg/analyzer/torture/pr104863.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com> Diff: --- gcc/analyzer/constraint-manager.cc | 4 ++++ gcc/testsuite/gcc.dg/analyzer/torture/pr104863.c | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index ac1e4feaee5..9c8c60429f4 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -1818,6 +1818,10 @@ constraint_manager::add_constraint (const svalue *lhs, = m_mgr->get_or_create_constant_svalue (offset_of_cst); if (!add_constraint (implied_lhs, implied_op, implied_rhs)) return false; + /* The above add_constraint could lead to EC merger, so we need + to refresh the EC IDs. */ + lhs_ec_id = get_or_add_equiv_class (lhs); + rhs_ec_id = get_or_add_equiv_class (rhs); } add_unknown_constraint (lhs_ec_id, op, rhs_ec_id); diff --git a/gcc/testsuite/gcc.dg/analyzer/torture/pr104863.c b/gcc/testsuite/gcc.dg/analyzer/torture/pr104863.c new file mode 100644 index 00000000000..30ed4fe022d --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/torture/pr104863.c @@ -0,0 +1,14 @@ +/* { dg-additional-options "-fanalyzer-transitivity" } */ +/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */ + +extern void g(); +struct a { +} b(int c, int d) { + struct a *e = 0; + int f; + if (c & 1 || !(c & 2)) + return *e; + f = 0; + for (; f < d - 1; f++) + g(e[1]); /* { dg-warning "dereference of NULL" } */ +}
reply other threads:[~2022-03-10 21:53 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220310215312.094783858D39@sourceware.org \ --to=dmalcolm@gcc.gnu.org \ --cc=gcc-cvs@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).