overlap of INTENT(IN) and INTENT(OUT) arguments



For the code

module foo_mod
contains
subroutine set_alloc(ii,jj)
! allocate jj and set it to ii
integer, intent(in) :: ii(:)
integer, intent(out), allocatable :: jj(:)
integer :: ni
ni = size(ii)
allocate (jj(ni))
jj = ii
write (*,*) "jj =",jj
end subroutine set_alloc
end module foo_mod

program xset_alloc
use foo_mod, only: set_alloc
implicit none
integer, allocatable :: ii(:)
allocate (ii(3))
ii = (/10,20,30/)
call set_alloc(ii([1,3]),ii)
call set_alloc(ii(1:1),ii)
call set_alloc(ii,ii)
end program xset_alloc

gfortran says at compile time

In file xxset_alloc.f90:23
call set_alloc(ii,ii)
Warning: Same actual argument associated with INTENT(OUT) argument
'jj' and INTENT(IN) argument 'ii' at (1)

and crashes at run time at line 23. G95 and Intel Fortran do not
complain at compile time and run to completion.
Are all three calls to set_alloc nonstandard? If they are, I can see
how warning about the 3rd case would be much easier than warning about
the first two.

.



Relevant Pages