https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37131
--- Comment #24 from Dominique d'Humieres <dominiq at lps dot ens.fr> --- Reduced test module tst implicit none contains subroutine bar (a, b, n, m) integer, dimension(:), allocatable, intent(inout) :: a integer, dimension(:), pointer, intent(inout) :: b integer, intent(out) :: n, m n = lbound(a,1) m = lbound(b,1) end subroutine bar end module tst program main use tst implicit none integer, dimension(:), allocatable :: x ! integer, dimension(:), allocatable, target :: x integer, dimension(:), pointer :: y integer :: n,m allocate (x(0)) ! y => x call bar (x, y, n, m) ! print *, m, n if (n .ne. 1 .or. m .ne. 1) call abort end program main gives Program aborted. Backtrace: #0 0x1020a0472 #1 0x1020a1612 #2 0x102176428 #3 0x102098ecb Abort The program runs without abort if (1) I uncomment the line ! print *, m, n (2) I uncomment the lines ! integer, dimension(:), allocatable, target :: x and ! y => x and I comment the line integer, dimension(:), allocatable :: x I wonder if the above code is valid Fortran.