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 r13-1773] analyzer: fix ICE on untracked decl_regions [PR106374]
Date: Thu, 21 Jul 2022 01:39:20 +0000 (GMT)	[thread overview]
Message-ID: <20220721013920.C9C7438346A4@sourceware.org> (raw)

https://gcc.gnu.org/g:a6c192e80a87efbe6c0641f25a963c7bee9990fb

commit r13-1773-ga6c192e80a87efbe6c0641f25a963c7bee9990fb
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Wed Jul 20 21:34:03 2022 -0400

    analyzer: fix ICE on untracked decl_regions [PR106374]
    
    gcc/analyzer/ChangeLog:
            PR analyzer/106374
            * region.cc (decl_region::get_svalue_for_initializer): Bail out on
            untracked regions.
    
    gcc/testsuite/ChangeLog:
            PR analyzer/106374
            * gcc.dg/analyzer/untracked-2.c: New test.
    
    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

Diff:
---
 gcc/analyzer/region.cc                      | 5 +++++
 gcc/testsuite/gcc.dg/analyzer/untracked-2.c | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc
index a8d1ae92deb..b78bf4ec1b7 100644
--- a/gcc/analyzer/region.cc
+++ b/gcc/analyzer/region.cc
@@ -1152,6 +1152,11 @@ decl_region::get_svalue_for_initializer (region_model_manager *mgr) const
       if (binding->symbolic_p ())
 	return NULL;
 
+      /* If we don't care about tracking the content of this region, then
+	 it's unused, and the value doesn't matter.  */
+      if (!tracked_p ())
+	return NULL;
+
       binding_cluster c (this);
       c.zero_fill_region (mgr->get_store_manager (), this);
       return mgr->get_or_create_compound_svalue (TREE_TYPE (m_decl),
diff --git a/gcc/testsuite/gcc.dg/analyzer/untracked-2.c b/gcc/testsuite/gcc.dg/analyzer/untracked-2.c
new file mode 100644
index 00000000000..565a9ccd58e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/untracked-2.c
@@ -0,0 +1,7 @@
+typedef unsigned char u8;
+extern int foo(const u8 *key, unsigned int keylen);
+int test (void)
+{
+  static const u8 default_salt[64];
+  return foo(default_salt, 64);
+}


                 reply	other threads:[~2022-07-21  1:39 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=20220721013920.C9C7438346A4@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: link
Be 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).