From 06eaa86f99c3576f1f47f48d79cfebaecac57225 Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Mon, 4 May 1998 19:16:35 +0000 Subject: [PATCH] Fix bug where storing into const string gives core dump, from Kamil Iskra. * expr.c (expand_expr, case INDIRECT_REF): Don't optimize string reference if this is a store. From-SVN: r19531 --- gcc/ChangeLog | 5 +++++ gcc/expr.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7038dbf6303..2c7d23c06a3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +Mon May 4 19:15:29 1998 Jim Wilson + + * expr.c (expand_expr, case INDIRECT_REF): Don't optimize string + reference if this is a store. + Mon May 4 17:25:17 1998 Richard Henderson * sparc.c (output_move_quad): Fix typo in mov_by_64 argument. diff --git a/gcc/expr.c b/gcc/expr.c index c094a0f0f02..8b8e5133b6a 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -5484,13 +5484,15 @@ expand_expr (exp, target, tmode, modifier) tree string = string_constant (exp1, &index); int i; + /* Try to optimize reads from const strings. */ if (string && TREE_CODE (string) == STRING_CST && TREE_CODE (index) == INTEGER_CST && !TREE_INT_CST_HIGH (index) && (i = TREE_INT_CST_LOW (index)) < TREE_STRING_LENGTH (string) && GET_MODE_CLASS (mode) == MODE_INT - && GET_MODE_SIZE (mode) == 1) + && GET_MODE_SIZE (mode) == 1 + && modifier != EXPAND_MEMORY_USE_WO) return GEN_INT (TREE_STRING_POINTER (string)[i]); op0 = expand_expr (exp1, NULL_RTX, VOIDmode, EXPAND_SUM); -- 2.30.2