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

--- Comment #1 from G. Steinmetz <gs...@t-online.de> ---

Works here with explicitly enforced evaluation (a(n)) :


$ cat z3.f90
program p
   integer :: a(4) = [-1, -2, -3, -4]
   integer :: n(4) = [4, 2, 1, 3]
   call s ((a(n)), a)
   print *, a
contains
   elemental subroutine s (x, y)
      integer, value :: x
      integer, intent(out) :: y
      y = x
   end
end


$ cat z8.f90
program p
   implicit none
   integer, parameter :: m = 99
   integer :: i
   integer :: a(m) = [(-i,i=1,m)]
   call s ((a(m:1:-1)), a)
   print '(10i6)', a
contains
   elemental subroutine s (x, y)
      integer, value :: x
      integer, intent(out) :: y
      y = x
   end
end


$ cat z9.f90
program p
   implicit none
   integer, parameter :: m = 99
   integer :: i
   integer :: a(m) = [(-i,i=1,m)]
   integer :: n(m) = [(i,i=m,1,-1)]
   call s ([a(n)], a)
   print '(10i6)', a
contains
   elemental subroutine s (x, y)
      integer, value :: x
      integer, intent(out) :: y
      y = x
   end
end


$ gfortran-13-20221120 z3.f90 && ./a.out
          -4          -2          -1          -3
$

Reply via email to