I am curious about the validity and conformity of the program below:
program point_expr
implicit none
integer, dimension(:), pointer :: ptr
integer :: i
! This does not work: not a target or pointer, as expected
!ptr => [(i, i = 1,10)]
!
! This gives the "right" results with gfortran, but with Intel Fortran oneAPI
! some entries are corrupted.
!
call assign_ptr( ptr, [(i, i = 1,10)] )
write(*,*) ptr
contains
subroutine assign_ptr( p, a )
integer, pointer :: p(:)
integer, target :: a(:)
p => a
end subroutine assign_ptr
end program point_expr
The background: I am looking for ways to reduce the amount of temporary memory and the copying of temporary arrays, while still using array operations. The program runs fine with gfortran and apparently does the “right” thing, but with Intel Fortran oneAPI I get rubbish:
1 2 3 4 -2088435968 288
7 8 13630048 223
So I wonder if the fact that it seems to work with gfortran is merely a coincidence. In neither case I get a warning or something. I suspect it is not conforming, but if it is, then I stumbled on a compiler error.