https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119118
--- Comment #6 from anlauf at gcc dot gnu.org ---
(In reply to anlauf from comment #5)
> (In reply to anlauf from comment #3)
> > diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
> > index fbe7333fd71..ed29623fcdf 100644
> > --- a/gcc/fortran/trans-expr.cc
> > +++ b/gcc/fortran/trans-expr.cc
> > @@ -2814,8 +2813,8 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int
> > kind,
> > end.expr = gfc_evaluate_now (end.expr, &se->pre);
> >
> > if ((gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
> > - && (ref->u.ss.start->symtree
> > - && !ref->u.ss.start->symtree->n.sym->attr.implied_index))
> > + && !(ref->u.ss.start->symtree
> > + && ref->u.ss.start->symtree->n.sym->attr.implied_index))
> > {
> > tree nonempty = fold_build2_loc (input_location, LE_EXPR,
> > logical_type_node, start.expr,
>
> This fix attempt reveals another problem. Changing in testcase
>
> gcc/testsuite/gfortran.dg/bounds_check_23.f90
>
> the line
>
> c = [ ( text(i:i), i = 1, len(text) ) ]
>
> to
>
> c = [ ( text(i+0:i), i = 1, len(text) ) ]
>
> which now crashes, as the bounds-checking code is evaluated outside the
> constructor.
I have a better patch.