!gfortran -fcray-pointer test.f90 program test use iso_c_binding integer x(*) pointer (px, x) integer, target :: y allocatable y type(c_ptr) py px = malloc(4) write(*, fmt='(Z16.16)') px call free(px) allocate(y) py = c_loc(y) write(*, fmt='(Z16.16)') py end program test