diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2017-12-21 16:22:04 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2017-12-21 16:22:04 +0000 |
commit | 6ffc0c0cf5ada5d74da5c0b68fade4b5ec0e944a (patch) | |
tree | 874f8fce52c1819336a08cb53bb1286a42af8cb7 | |
parent | b3eec1d68892e17c6f788a6ee723d44e97498c9d (diff) | |
download | gcc-6ffc0c0cf5ada5d74da5c0b68fade4b5ec0e944a.zip gcc-6ffc0c0cf5ada5d74da5c0b68fade4b5ec0e944a.tar.gz gcc-6ffc0c0cf5ada5d74da5c0b68fade4b5ec0e944a.tar.bz2 |
re PR c++/82872 (ICE in ignore_overflows on __PTRDIFF_MAX__ index)
PR c++/82872
* convert.c (convert_to_integer_1) <POINTER_TYPE>: Do not return the
shared zero if the input has overflowed.
From-SVN: r255944
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/convert.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/c-c++-common/pr82872.c | 11 |
4 files changed, 22 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b1846ac..d364df4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-12-21 Eric Botcazou <ebotcazou@adacore.com> + + PR c++/82872 + * convert.c (convert_to_integer_1) <POINTER_TYPE>: Do not return the + shared zero if the input has overflowed. + 2017-12-21 Kyrylo Tkachov <kyrylo.tkachov@arm.com> * config/arm/driver-arm.c (arm_cpu_table): Specify dotprod diff --git a/gcc/convert.c b/gcc/convert.c index 0045c12..25aa5ad 100644 --- a/gcc/convert.c +++ b/gcc/convert.c @@ -671,7 +671,7 @@ convert_to_integer_1 (tree type, tree expr, bool dofold) { case POINTER_TYPE: case REFERENCE_TYPE: - if (integer_zerop (expr)) + if (integer_zerop (expr) && !TREE_OVERFLOW (expr)) return build_int_cst (type, 0); /* Convert to an unsigned integer of the correct width first, and from diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 932ff87..a607911 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-12-21 Eric Botcazou <ebotcazou@adacore.com> + + * c-c++-common/pr82872.c: New test. + 2017-12-21 Jakub Jelinek <jakub@redhat.com> PR rtl-optimization/82973 diff --git a/gcc/testsuite/c-c++-common/pr82872.c b/gcc/testsuite/c-c++-common/pr82872.c new file mode 100644 index 0000000..745d622 --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr82872.c @@ -0,0 +1,11 @@ +/* PR c++/82872 */ +/* { dg-do compile } */ + +#include <stddef.h> + +struct S { int i, a[1]; }; + +size_t foo (void) +{ + return offsetof (struct S, a[__PTRDIFF_MAX__]); +} |