From c813f2686aa230cf20ca954dee94b1019b7c364b Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Thu, 22 Sep 2016 12:15:38 +0000 Subject: [PATCH] re PR fortran/77678 (ICE in fold_read_from_constant_string, at fold-const.c:13706) 2016-09-22 Richard Biener PR middle-end/77678 * expr.c (expand_expr_real_1): Guard array access against negative offset. From-SVN: r240351 --- gcc/ChangeLog | 6 ++++++ gcc/expr.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 485d80887b8..9b1792596fc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-09-22 Richard Biener + + PR middle-end/77678 + * expr.c (expand_expr_real_1): Guard array access against negative + offset. + 2016-09-22 Rainer Orth * gimple-ssa-sprintf.c (format_floating_max): Use GMP_RNDN instead diff --git a/gcc/expr.c b/gcc/expr.c index 73e000efca6..2e97030c5b8 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -10274,7 +10274,8 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, fold_convert_loc (loc, sizetype, low_bound)); - if (compare_tree_int (index1, TREE_STRING_LENGTH (init)) < 0) + if (tree_fits_uhwi_p (index1) + && compare_tree_int (index1, TREE_STRING_LENGTH (init)) < 0) { tree type = TREE_TYPE (TREE_TYPE (init)); machine_mode mode = TYPE_MODE (type); -- 2.30.2