re PR fortran/77678 (ICE in fold_read_from_constant_string, at fold-const.c:13706)
authorRichard Biener <rguenther@suse.de>
Thu, 22 Sep 2016 12:15:38 +0000 (12:15 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 22 Sep 2016 12:15:38 +0000 (12:15 +0000)
2016-09-22  Richard Biener  <rguenther@suse.de>

PR middle-end/77678
* expr.c (expand_expr_real_1): Guard array access against negative
offset.

From-SVN: r240351

gcc/ChangeLog
gcc/expr.c

index 485d80887b87fb399364045e1ecafc6885c5b8a0..9b1792596fc0da72d10700a47c54f79cbf2d6d5e 100644 (file)
@@ -1,3 +1,9 @@
+2016-09-22  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/77678
+       * expr.c (expand_expr_real_1): Guard array access against negative
+       offset.
+
 2016-09-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * gimple-ssa-sprintf.c (format_floating_max): Use GMP_RNDN instead
index 73e000efca65351c7c2cc7e1a4a9e58c9f0dfcbe..2e97030c5b884b046fa6d2867f5c63680f32af85 100644 (file)
@@ -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);