diff options
author | Richard Biener <rguenther@suse.de> | 2017-02-28 15:31:30 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2017-02-28 15:31:30 +0000 |
commit | 587240d2494dae65fd67d5bd642a6123ecc89738 (patch) | |
tree | fb6b142c18c450fd08dd5ca487b0e78cf0a099e9 | |
parent | 324ff1a07f9ddde87f91acfa7b16a3c24ba6895c (diff) | |
download | gcc-587240d2494dae65fd67d5bd642a6123ecc89738.zip gcc-587240d2494dae65fd67d5bd642a6123ecc89738.tar.gz gcc-587240d2494dae65fd67d5bd642a6123ecc89738.tar.bz2 |
re PR c/79731 (ICE: verify_gimple failed)
2017-02-28 Richard Biener <rguenther@suse.de>
PR middle-end/79731
* fold-const.c (decode_field_reference): Reject out-of-bound
accesses.
* c-c++-common/torture/pr79731.c: New testcase.
From-SVN: r245779
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 6 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/torture/pr79731.c | 18 |
4 files changed, 34 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 87478ee..b65f820 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-02-28 Richard Biener <rguenther@suse.de> + + PR middle-end/79731 + * fold-const.c (decode_field_reference): Reject out-of-bound + accesses. + 2017-02-28 Jakub Jelinek <jakub@redhat.com> * config/i386/i386.c: Include intl.h. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ad4770b..3d63836 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -4133,7 +4133,11 @@ decode_field_reference (location_t loc, tree *exp_, HOST_WIDE_INT *pbitsize, punsignedp, preversep, pvolatilep); if ((inner == exp && and_mask == 0) || *pbitsize < 0 || offset != 0 - || TREE_CODE (inner) == PLACEHOLDER_EXPR) + || TREE_CODE (inner) == PLACEHOLDER_EXPR + /* Reject out-of-bound accesses (PR79731). */ + || (! AGGREGATE_TYPE_P (TREE_TYPE (inner)) + && compare_tree_int (TYPE_SIZE (TREE_TYPE (inner)), + *pbitpos + *pbitsize) < 0)) return 0; *exp_ = exp; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b616b8a..82933d3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2017-02-28 Richard Biener <rguenther@suse.de> + PR middle-end/79731 + * c-c++-common/torture/pr79731.c: New testcase. + +2017-02-28 Richard Biener <rguenther@suse.de> + PR tree-optimization/79732 * gcc.dg/torture/pr79732.c: New testcase. diff --git a/gcc/testsuite/c-c++-common/torture/pr79731.c b/gcc/testsuite/c-c++-common/torture/pr79731.c new file mode 100644 index 0000000..cde2655 --- /dev/null +++ b/gcc/testsuite/c-c++-common/torture/pr79731.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-Wno-psabi -w" } */ + +typedef unsigned V __attribute__ ((vector_size (8))); +V +foo (unsigned x, V v) +{ + do { + v %= x; + x = 1; + } while (v[1]); + return v; +} +void fn2 () +{ + V x = foo (5, (V) { 0, 1 }); + if (x[0] || x[1] || x[2] || x[3]); +} |