Reproducer: """ $ cat sk.f program test c this program tests memory allocation c write(*,*)"Enter an interger higher than 0" c read(*,*)k k=1 call test_cray(k) end subroutine test_cray(k) c integer*8 ptrzz1 pointer(ptrzz1 , zz1) ptrzz1=0 c ptrzz1=loc(zz1) write(*,*)" ptrzz1: ",ptrzz1 if (ptrzz1 .ne. 0) then write(*,*)" ptrzz1 ne zero in the calling routine" else write(*,*)" ptrzz1 eq zero in the calling routine" call shape_cray(zz1) write(*,*)"*** Returning from shape_cray" end if end subroutine shape_cray(zz1) pointer(ptrzz , zz) ptrzz=loc(zz1) if (ptrzz .ne. 0) then write(*,*)" ptrzz - loc(zz1)- ne zero in the called routine" write(*,*)" ptrzz: ",ptrzz else write(*,*)" ptrzz - loc(zz1) eq zero in the called routine" write(*,*)" ptrzz: ",ptrzz end if c write(*,*)" ptrzz: ",ptrzz end $ gfortran -frecursive -fPIC -ffixed-line-length-132 -fautomatic -fcray-pointer -O1 -o test sk.f $ ./test ptrzz1: 0 ptrzz1 eq zero in the calling routine ptrzz - loc(zz1)- ne zero in the called routine ptrzz: 0 *** Returning from shape_cray """ If compiled with -O0 it works as expected: """ $ gfortran -frecursive -fPIC -ffixed-line-length-132 -fautomatic -fcray-pointer -O0 -o test sk.f $ ./test ptrzz1: 0 ptrzz1 eq zero in the calling routine ptrzz - loc(zz1) eq zero in the called routine ptrzz: 0 *** Returning from shape_cray """
Reproduced. Started with r238754. Reduced test: program test k=1 call test_cray(k) end subroutine test_cray(k) pointer(ptrzz1 , zz1) ptrzz1=0 if (ptrzz1 .ne. 0) then call abort() else call shape_cray(zz1) end if end subroutine shape_cray(zz1) pointer(ptrzz , zz) ptrzz=loc(zz1) if (ptrzz .ne. 0) then call abort() end if end I have to file an upstream bug.
Upstream PR filed. This needs to be dealt with in upstream first.