public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Martin Sebor <msebor@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5861] Use the recursive form of compute_objsize [PR 103143].
Date: Thu,  9 Dec 2021 16:52:00 +0000 (GMT)	[thread overview]
Message-ID: <20211209165200.26A9B385841F@sourceware.org> (raw)

https://gcc.gnu.org/g:425a39fd4effd9604af9f5f0780d209036d6e886

commit r12-5861-g425a39fd4effd9604af9f5f0780d209036d6e886
Author: Martin Sebor <msebor@redhat.com>
Date:   Sat Dec 4 16:22:07 2021 -0700

    Use the recursive form of compute_objsize [PR 103143].
    
    gcc/ChangeLog:
    
            PR middle-end/103143
            * pointer-query.cc (gimple_call_return_array): Call compute_objsize_r.
    
    gcc/testsuite/ChangeLog:
            PR middle-end/103143
            * gcc.dg/Wstringop-overflow-83.c: New test.

Diff:
---
 gcc/pointer-query.cc                         |  2 +-
 gcc/testsuite/gcc.dg/Wstringop-overflow-83.c | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/gcc/pointer-query.cc b/gcc/pointer-query.cc
index 2ead0271617..25ce4303849 100644
--- a/gcc/pointer-query.cc
+++ b/gcc/pointer-query.cc
@@ -199,7 +199,7 @@ gimple_call_return_array (gimple *stmt, offset_int offrng[2], bool *past_end,
 	       of the source object.  */
 	    access_ref aref;
 	    tree src = gimple_call_arg (stmt, 1);
-	    if (compute_objsize (src, stmt, 1, &aref, qry)
+	    if (compute_objsize_r (src, stmt, 1, &aref, snlim, qry)
 		&& aref.sizrng[1] < offrng[1])
 	      offrng[1] = aref.sizrng[1];
 	  }
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-83.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-83.c
new file mode 100644
index 00000000000..6928ee4d559
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-83.c
@@ -0,0 +1,19 @@
+/* PR  middle-end/103143 - ICE due to infinite recursion in pointer-query.cc
+   { dg-do compile }
+   { dg-options "-O2 -Wall" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+void foo (size_t x)
+{
+  struct T { char buf[64]; char buf2[64]; } t;
+  char *p = &t.buf[8];
+  char *r = t.buf2;
+  size_t i;
+
+  for (i = 0; i < x; i++)
+    {
+      r = __builtin_mempcpy (r, p, i);
+      p = r + 1;
+    }
+}


                 reply	other threads:[~2021-12-09 16:52 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=20211209165200.26A9B385841F@sourceware.org \
    --to=msebor@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).