[Bug fortran/77678] ICE in fold_read_from_constant_string, at fold-const.c:13706
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77678 Thomas Koenig changed: What|Removed |Added Status|NEW |RESOLVED CC||tkoenig at gcc dot gnu.org Resolution|--- |FIXED --- Comment #9 from Thomas Koenig --- (In reply to kargl from comment #8) > I think that this should be closed. Yes.
[Bug fortran/77678] ICE in fold_read_from_constant_string, at fold-const.c:13706
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77678 --- Comment #8 from kargl at gcc dot gnu.org --- (In reply to kargl from comment #6) > (In reply to Richard Biener from comment #5) > > ICE fixed. > > Add -fcheck=all to your command line options. > > With the ICE fixed, I think that this falls squarely in the > WONTFIX or INVALID category. It is the user's responsibility > to check if the value of i is within the bounds of the string. > > > % gfc7 -o z -O2 -fcheck=all -finit-integer=-123456 a.f90 && ./z > At line 5 of file a.f90 > Fortran runtime error: Substring out of bounds: lower bound (-123456) > is less than one I think that this should be closed.
[Bug fortran/77678] ICE in fold_read_from_constant_string, at fold-const.c:13706
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77678 --- Comment #7 from Martin Liška --- Richi: Can the bug be marked as resolved?
[Bug fortran/77678] ICE in fold_read_from_constant_string, at fold-const.c:13706
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77678 kargl at gcc dot gnu.org changed: What|Removed |Added CC||kargl at gcc dot gnu.org --- Comment #6 from kargl at gcc dot gnu.org --- (In reply to Richard Biener from comment #5) > ICE fixed. Add -fcheck=all to your command line options. With the ICE fixed, I think that this falls squarely in the WONTFIX or INVALID category. It is the user's responsibility to check if the value of i is within the bounds of the string. % gfc7 -o z -O2 -fcheck=all -finit-integer=-123456 a.f90 && ./z At line 5 of file a.f90 Fortran runtime error: Substring out of bounds: lower bound (-123456) is less than one
[Bug fortran/77678] ICE in fold_read_from_constant_string, at fold-const.c:13706
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77678 Richard Biener changed: What|Removed |Added Keywords|ice-on-invalid-code | --- Comment #5 from Richard Biener --- ICE fixed.
[Bug fortran/77678] ICE in fold_read_from_constant_string, at fold-const.c:13706
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77678 --- Comment #4 from Richard Biener --- Author: rguenth Date: Thu Sep 22 12:15:38 2016 New Revision: 240351 URL: https://gcc.gnu.org/viewcvs?rev=240351&root=gcc&view=rev Log: 2016-09-22 Richard Biener PR middle-end/77678 * expr.c (expand_expr_real_1): Guard array access against negative offset. Modified: trunk/gcc/ChangeLog trunk/gcc/expr.c
[Bug fortran/77678] ICE in fold_read_from_constant_string, at fold-const.c:13706
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77678 Richard Biener changed: What|Removed |Added Keywords||accepts-invalid --- Comment #3 from Richard Biener --- I have a patch for the ICE. Index: gcc/expr.c === --- gcc/expr.c (revision 240342) +++ gcc/expr.c (working copy) @@ -10274,7 +10257,8 @@ expand_expr_real_1 (tree exp, rtx target 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);
[Bug fortran/77678] ICE in fold_read_from_constant_string, at fold-const.c:13706
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77678 Martin Liška changed: What|Removed |Added Keywords||ice-on-invalid-code Status|UNCONFIRMED |NEW Last reconfirmed||2016-09-22 CC||marxin at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Martin Liška --- Confirmed, all releases I have (4.5.0+) are affected. For the second example, we ICE in expansion of: _1 = c[-12345678]{lb: 1 sz: 1}; where c: static character(kind=1) c[1:3] = "abc";
[Bug fortran/77678] ICE in fold_read_from_constant_string, at fold-const.c:13706
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77678 --- Comment #1 from Gerhard Steinmetz --- Slightly modified : $ cat z2.f90 program p character(3) :: c = 'abc' character(1) :: z integer :: i ! i = 2 z = c(i:i) print *, z end $ gfortran-7-20160918 -O2 -finit-integer=-1 z2.f90 $ gfortran-7-20160918 -O2 -finit-integer=-890 z2.f90 $ gfortran-7-20160918 -O2 -finit-integer=-12345678 z2.f90 z2.f90:6:0: z = c(i:i) internal compiler error: Segmentation fault 0xc21a5f crash_signal ../../gcc/toplev.c:336 0x9053b7 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/expr.c:10284 0x9077f8 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool) ../../gcc/expr.c:9725 0x912cf6 store_expr_with_bounds(tree_node*, rtx_def*, int, bool, bool, tree_node*) ../../gcc/expr.c:5547 0x9147d7 expand_assignment(tree_node*, tree_node*, bool) ../../gcc/expr.c:5167 0x802cb6 expand_gimple_stmt_1 ../../gcc/cfgexpand.c:3649 0x802cb6 expand_gimple_stmt ../../gcc/cfgexpand.c:3745 0x8050ce expand_gimple_basic_block ../../gcc/cfgexpand.c:5752 0x80b276 execute ../../gcc/cfgexpand.c:6363