+2008-12-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/35468
+ * tree-ssa-ccp.c (fold_stmt_r): Don't fold reads from constant
+ string on LHS.
+
2008-12-09 Richard Guenther <rguenther@suse.de>
PR tree-optimization/38445
+2008-12-09 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/35468
+ * gcc.dg/pr35468.c: New test.
+ * gcc.c-torture/compile/pr35468.c: New test.
+
2008-12-08 Jason Merrill <jason@redhat.com>
PR c++/38410
--- /dev/null
+/* PR tree-optimization/35468 */
+/* { dg-do compile }*/
+/* { dg-options "-O2 -fno-tree-dce" } */
+
+char *const f(void)
+{
+ char *const line = "/dev/ptyXX";
+ line[8] = 1;
+ return line;
+}
t = maybe_fold_stmt_indirect (expr, TREE_OPERAND (expr, 0),
integer_zero_node);
+ /* Avoid folding *"abc" = 5 into 'a' = 5. */
+ if (wi->is_lhs && t && TREE_CODE (t) == INTEGER_CST)
+ t = NULL_TREE;
if (!t
&& TREE_CODE (TREE_OPERAND (expr, 0)) == ADDR_EXPR)
/* If we had a good reason for propagating the address here,
Otherwise we'd be wasting time. */
case ARRAY_REF:
/* If we are not processing expressions found within an
- ADDR_EXPR, then we can fold constant array references. */
- if (!*inside_addr_expr_p)
+ ADDR_EXPR, then we can fold constant array references.
+ Don't fold on LHS either, to avoid folding "abc"[0] = 5
+ into 'a' = 5. */
+ if (!*inside_addr_expr_p && !wi->is_lhs)
t = fold_read_from_constant_string (expr);
else
t = NULL;