re PR middle-end/54321 (ice in tree_low_cst at -O3)
authorJakub Jelinek <jakub@redhat.com>
Mon, 20 Aug 2012 09:12:05 +0000 (11:12 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 20 Aug 2012 09:12:05 +0000 (11:12 +0200)
PR tree-optimization/54321
* tree-ssa-forwprop.c (simplify_builtin_call): Pass 0 instead of 1
as second argument to tree_low_cst call on val2.

* gcc.c-torture/compile/pr54321.c: New test.

From-SVN: r190526

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr54321.c [new file with mode: 0644]
gcc/tree-ssa-forwprop.c

index 4ecef15..04c1dfa 100644 (file)
@@ -1,3 +1,9 @@
+2012-08-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/54321
+       * tree-ssa-forwprop.c (simplify_builtin_call): Pass 0 instead of 1
+       as second argument to tree_low_cst call on val2.
+
 2012-08-20  Richard Guenther  <rguenther@suse.de>
 
        * gimple.h (gimple_statement_base): Annotate with GTY chain_next.
index c115e55..3ef6c94 100644 (file)
@@ -1,3 +1,8 @@
+2012-08-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/54321
+       * gcc.c-torture/compile/pr54321.c: New test.
+
 2012-08-20  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/54301
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr54321.c b/gcc/testsuite/gcc.c-torture/compile/pr54321.c
new file mode 100644 (file)
index 0000000..13adc78
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR tree-optimization/54321 */
+struct S { char s[0]; } *a;
+
+void
+foo (void)
+{
+  char *b = a->s;
+  int c = 0;
+  b[0] = 0;
+  while (++c < 9)
+    b[c] = 255;
+}
index 78e17a5..bd9b72b 100644 (file)
@@ -1554,7 +1554,7 @@ simplify_builtin_call (gimple_stmt_iterator *gsi_p, tree callee2)
          else
            src_buf[0] = tree_low_cst (src1, 0);
          memset (src_buf + tree_low_cst (diff, 1),
-                 tree_low_cst (val2, 1), tree_low_cst (len2, 1));
+                 tree_low_cst (val2, 0), tree_low_cst (len2, 1));
          src_buf[src_len] = '\0';
          /* Neither builtin_strncpy_read_str nor builtin_memcpy_read_str
             handle embedded '\0's.  */