https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99359

            Bug ID: 99359
           Summary: Unexpected result of the allocation status when the
                    allocatable variable has been deallocated
           Product: gcc
           Version: 10.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yao....@compiler-dev.com
  Target Milestone: ---

the test case is:
module m
  type :: my_type3
    integer :: i
  end type
  type :: my_type2
    type(my_type3), allocatable :: dt3
  end type
  type :: my_type1
    type(my_type2), allocatable :: dt2
  end type
  type(my_type1), allocatable, target :: t1
  type(my_type1), pointer :: pt1
  type(my_type2), pointer :: pt2
end module

program test
  use m
  allocate(t1)
  allocate(t1%dt2)
  allocate(t1%dt2%dt3)
  t1%dt2%dt3%i = 7
  pt1 => t1
  pt2 => t1%dt2
  deallocate(t1%dt2%dt3)
  deallocate(t1%dt2)
  deallocate(t1)
  print *, associated(pt1), associated(pt2)
  print *, allocated(pt1%dt2), allocated(pt2%dt3)
end

the result under gfortran 10.1.0 is:
 T T
 T T
the result under ifort 19.1.1 is:
 T T
 F F
the result under flang is:
 T T
 F F

probably, deallocate allocatable variables will causes pointer be disassociated
or be associate other unexpect target?
But, why the status of associated is ture and why the allocation status under
ifort or flang is false?

Reply via email to