When an array of characters is an argument to a subroutine and
is accessed using (:)(1:) an ICE occurs. The upper bound of the
substring does not have an expression and such should not have
a Scalarization State structure added to the Scalarization State
chain.
2020-07-29 Mark Eggleston <markeggleston@gcc.gnu.org>
gcc/fortran/
PR fortran/53298
* trans-array.c (gfc_walk_array_ref): If ref->ss.end is set
call gfc_get_scalar_ss.
2020-07-29 Mark Eggleston <markeggleston@gcc.gnu.org>
gcc/testsuite/
PR fortran/53298
* gfortran.dg/pr53298.f90: New test.
if (ref->type == REF_SUBSTRING)
{
ss = gfc_get_scalar_ss (ss, ref->u.ss.start);
- ss = gfc_get_scalar_ss (ss, ref->u.ss.end);
+ if (ref->u.ss.end)
+ ss = gfc_get_scalar_ss (ss, ref->u.ss.end);
}
/* We're only interested in array sections from now on. */
--- /dev/null
+! { dg-do run }
+
+program test
+ character(len=5) :: str(3)
+ str = ["abcde", "12345", "ABCDE" ]
+ call f(str(:))
+contains
+ subroutine f(x)
+ character(len=*) :: x(:)
+ write(*,*) x(:)(1:)
+ end subroutine f
+end program test
+
+! { dg-output "abcde12345ABCDE" }