can this be treated as bug in fortran?

Uttam Pawar uttamp@us.ibm.com
Wed Nov 16 18:37:00 GMT 2005


> May be I can do this with allocatable pointer too?

following is another case of dangling pointer.

cat test.f90
program test2
  integer, allocatable, target :: ptr1(:)
  integer, pointer :: ptr2(:)
  allocate(ptr1(10))
  ptr1 = 10; ptr2 => ptr1
  call free_ptr
  ptr2 = 20
  print *, "should not reach here"
contains
  subroutine free_ptr
    deallocate(ptr1)
  end subroutine free_ptr
end program test2



More information about the Fortran mailing list