aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-12-04 16:22:07 -0700
committerMartin Sebor <msebor@redhat.com>2021-12-09 09:51:47 -0700
commit425a39fd4effd9604af9f5f0780d209036d6e886 (patch)
tree1a2eb6d8a49afd8a636f5b4b3398ecc1b042e2cf
parent6a071b2d40a1078b4029c2b77ef29ffca4e7050c (diff)
downloadgcc-425a39fd4effd9604af9f5f0780d209036d6e886.zip
gcc-425a39fd4effd9604af9f5f0780d209036d6e886.tar.gz
gcc-425a39fd4effd9604af9f5f0780d209036d6e886.tar.bz2
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.
-rw-r--r--gcc/pointer-query.cc2
-rw-r--r--gcc/testsuite/gcc.dg/Wstringop-overflow-83.c19
2 files changed, 20 insertions, 1 deletions
diff --git a/gcc/pointer-query.cc b/gcc/pointer-query.cc
index 2ead027..25ce430 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 0000000..6928ee4
--- /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;
+ }
+}