[Bug fortran/98490] Unexpected out of bounds in array constructor with implied do loop

sgk at troutmask dot apl.washington.edu gcc-bugzilla@gcc.gnu.org
Sat Jan 2 21:03:40 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98490

--- Comment #7 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
On Sat, Jan 02, 2021 at 04:12:27AM +0000, jvdelisle at charter dot net wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98490
> 
> --- Comment #5 from Jerry DeLisle <jvdelisle at charter dot net> ---
> Patch regresses several test cases.
>

This regresses okay.

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 14361a10f68..b860f7eaa26 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -2537,7 +2537,9 @@ gfc_conv_substring (gfc_se * se, gfc_ref * ref, int kind,
   if (!CONSTANT_CLASS_P (tmp) && !DECL_P (tmp))
     end.expr = gfc_evaluate_now (end.expr, &se->pre);

-  if (gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
+  if ((gfc_option.rtcheck & GFC_RTCHECK_BOUNDS)
+      && (ref->u.ss.start->symtree
+   && !ref->u.ss.start->symtree->n.sym->attr.implied_index))
     {
       tree nonempty = fold_build2_loc (input_location, LE_EXPR,

My test program without the dejagnu stuff.

program test

   implicit none

   call sub('Lorem ipsum')

   contains

      subroutine sub( text )
         character(len=*), intent(in) :: text
         character(len=1), allocatable ::c(:)
         integer :: i
         c = [ ( text(i:i), i = 1, len(text) ) ]
         if (c(1) /= 'L') stop 1
      end subroutine sub

end program test


More information about the Gcc-bugs mailing list