diff options
author | Martin Sebor <msebor@redhat.com> | 2019-01-17 22:52:47 +0000 |
---|---|---|
committer | Martin Sebor <msebor@gcc.gnu.org> | 2019-01-17 15:52:47 -0700 |
commit | 77efc5c25c487ce50ff94bdee7494c6a87fda4f1 (patch) | |
tree | 5d6d1107a319bf0a98f7b83194157e2f7d111078 /gcc | |
parent | 17ad43dd4c5dc1a39165a6b2108f4ea793e15eed (diff) | |
download | gcc-77efc5c25c487ce50ff94bdee7494c6a87fda4f1.zip gcc-77efc5c25c487ce50ff94bdee7494c6a87fda4f1.tar.gz gcc-77efc5c25c487ce50ff94bdee7494c6a87fda4f1.tar.bz2 |
PR middle-end/88273 - [8/9 Regression] warning: 'memcpy' offset [-527, -529]
PR middle-end/88273 - [8/9 Regression] warning: 'memcpy' offset [-527, -529]
is out of the bounds [0, 16]
gcc/ChangeLog:
PR middle-end/88273
* gimple-ssa-warn-restrict.c (builtin_memref::extend_offset_range):
Handle anti-ranges the same as no range at all.
gcc/testsuite/ChangeLog:
PR middle-end/88273
* gcc.dg/Warray-bounds-38.c: New test.
From-SVN: r268048
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/gimple-ssa-warn-restrict.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/Warray-bounds-38.c | 30 |
4 files changed, 42 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b3649d1..32b153a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-01-17 Martin Sebor <msebor@redhat.com> + + PR middle-end/88273 + * gimple-ssa-warn-restrict.c (builtin_memref::extend_offset_range): + Handle anti-ranges the same as no range at all. + 2018-01-17 Steve Ellcey <sellcey@cavium.com> * config/aarch64/aarch64.c (cgraph.h): New include. diff --git a/gcc/gimple-ssa-warn-restrict.c b/gcc/gimple-ssa-warn-restrict.c index 42c87190..b069f3a 100644 --- a/gcc/gimple-ssa-warn-restrict.c +++ b/gcc/gimple-ssa-warn-restrict.c @@ -319,13 +319,9 @@ builtin_memref::extend_offset_range (tree offset) offrange[0] += offset_int::from (min, SIGNED); offrange[1] += offset_int::from (max, SIGNED); } - else if (rng == VR_ANTI_RANGE) - { - offrange[0] += offset_int::from (max + 1, SIGNED); - offrange[1] += offset_int::from (min - 1, SIGNED); - } else { + /* Handle an anti-range the same as no range at all. */ gimple *stmt = SSA_NAME_DEF_STMT (offset); tree type; if (is_gimple_assign (stmt) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 84cb714..790556f1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-17 Martin Sebor <msebor@redhat.com> + + PR middle-end/88273 + * gcc.dg/Warray-bounds-38.c: New test. + 2018-01-17 Steve Ellcey <sellcey@cavium.com> * c-c++-common/gomp/pr60823-1.c: Add aarch64 specific diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-38.c b/gcc/testsuite/gcc.dg/Warray-bounds-38.c new file mode 100644 index 0000000..c9aa0eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-bounds-38.c @@ -0,0 +1,30 @@ +/* PR middle-end/88273 - bogus warning: 'memcpy' offset [-527, -529] + is out of the bounds [0, 16] + { dg-do compile } + { dg-options "-O2 -Wall" } */ + +typedef __SIZE_TYPE__ size_t; + +void *q; + +size_t x, y; + +inline void f (char *p, int i, size_t j) +{ + size_t n = y ? y : j; + + p += x - i; + + __builtin_memcpy (q, p, n); /* { dg-bogus "bounds" } */ + + x = n; +} + +void g (void) +{ + struct { char a[16]; } s; + + f (q, 0, sizeof s); + + f (s.a, 33 * sizeof s, 1); +} |