aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.6
diff options
context:
space:
mode:
authorAlexander Ivchenko <alexander.ivchenko@intel.com>2013-05-24 14:38:09 +0400
committerAlexander Ivchenko <alexander.ivchenko@intel.com>2013-05-24 14:43:52 +0400
commitf63aa0156b8ef6b30304890529cbf642e8f78ebd (patch)
treeecc99cc5a33632230d97afcf9ecc0737bb49f82a /gcc-4.6
parent19cf682fd52c042ec6b988ef294dacc45fa50944 (diff)
downloadtoolchain_gcc-f63aa0156b8ef6b30304890529cbf642e8f78ebd.zip
toolchain_gcc-f63aa0156b8ef6b30304890529cbf642e8f78ebd.tar.gz
toolchain_gcc-f63aa0156b8ef6b30304890529cbf642e8f78ebd.tar.bz2
[4.6], [4.7], [4.8] Backport of the patch from trunk/4.8 for fixing
this issue: https://code.google.com/p/android/issues/detail?id=54623 2013-05-24 Alexander Ivchenko <alexander.ivchenko@intel.com> PR tree-ssa/57385 * tree-ssa-sccvn.c (fully_constant_vn_reference_p): Check that index is not negative. Change-Id: I8c83a3f9992b60d3f59c2b8e123ecda7c398d07e Signed-off-by: Alexander Ivchenko <alexander.ivchenko@intel.com>
Diffstat (limited to 'gcc-4.6')
-rw-r--r--gcc-4.6/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c10
-rw-r--r--gcc-4.6/gcc/tree-ssa-sccvn.c1
2 files changed, 11 insertions, 0 deletions
diff --git a/gcc-4.6/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c b/gcc-4.6/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
new file mode 100644
index 0000000..fc21461
--- /dev/null
+++ b/gcc-4.6/gcc/testsuite/gcc.dg/tree-ssa/pr57385.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+int c;
+
+void foo(int f)
+{
+ int wbi=-100000000;
+ c = (f ? "012346000000000000":"01345:000000006008")[wbi];
+}
diff --git a/gcc-4.6/gcc/tree-ssa-sccvn.c b/gcc-4.6/gcc/tree-ssa-sccvn.c
index eb88969..704a86c 100644
--- a/gcc-4.6/gcc/tree-ssa-sccvn.c
+++ b/gcc-4.6/gcc/tree-ssa-sccvn.c
@@ -1115,6 +1115,7 @@ fully_constant_vn_reference_p (vn_reference_t ref)
== TYPE_MODE (TREE_TYPE (TREE_TYPE (arg0->op0))))
&& GET_MODE_CLASS (TYPE_MODE (op->type)) == MODE_INT
&& GET_MODE_SIZE (TYPE_MODE (op->type)) == 1
+ && tree_int_cst_sgn (op->op0) >= 0
&& compare_tree_int (op->op0, TREE_STRING_LENGTH (arg0->op0)) < 0)
return build_int_cst_type (op->type,
(TREE_STRING_POINTER (arg0->op0)