From: Richard Biener Date: Wed, 16 Sep 2015 14:26:04 +0000 (+0000) Subject: re PR middle-end/67271 (ICE with -O1,2,3 on darwin14.5 x86_64) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=486bc8471fd5de49262f2b36a17b1be5915436e1;p=gcc.git re PR middle-end/67271 (ICE with -O1,2,3 on darwin14.5 x86_64) 2015-09-16 Richard Biener PR middle-end/67271 * fold-const.c (native_encode_expr): Bail out on bogus offsets. * gcc.dg/pr67271.c: New testcase. From-SVN: r227825 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 085de31e554..2ec6aefd507 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-09-16 Richard Biener + + PR middle-end/67271 + * fold-const.c (native_encode_expr): Bail out on bogus offsets. + 2015-09-16 Eric Botcazou * tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Use offset_int for diff --git a/gcc/fold-const.c b/gcc/fold-const.c index fd1c87ed5ad..15214507f08 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7110,6 +7110,10 @@ native_encode_string (const_tree expr, unsigned char *ptr, int len, int off) int native_encode_expr (const_tree expr, unsigned char *ptr, int len, int off) { + /* We don't support starting at negative offset and -1 is special. */ + if (off < -1) + return 0; + switch (TREE_CODE (expr)) { case INTEGER_CST: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 945db718bd0..87bcebfd00f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-09-16 Richard Biener + + PR middle-end/67271 + * gcc.dg/pr67271.c: New testcase. + 2015-09-16 Eric Botcazou * gnat.dg/opt49.adb: New test. diff --git a/gcc/testsuite/gcc.dg/pr67271.c b/gcc/testsuite/gcc.dg/pr67271.c new file mode 100644 index 00000000000..b6988a39174 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr67271.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +extern long int labs (long int j); +int +main () +{ + long *a = (long *)"empty"; + int i = 1441516387; + a[i] = labs (a[i]); + return 0; +}