Skip to content

[flang] Runtime error of Invalid descriptor when deallocate an allocated pointer. #165055

@DanielCChen

Description

@DanielCChen

Consider the following code:

module m
    type base
        integer :: id
    end type

    type container
        !class (base), pointer :: data => null()
        type(base), pointer :: data => null()
    end type

    contains

    pure function makeData (i)
        type (base), pointer :: makeData
        integer*4, intent(in) :: i

        allocate (makeData)

        makeData = base(i)
    end function


end module

program fpAssgn016
use m
    type (container) :: co1(10)

   forall (i=1:10)
!   do i = 1,10                           !! work around
        co1(i)%data => makeData (i)
!   end do
    end forall

    do i =1, 10
        deallocate (co1(i)%data)
    end do

end

Flang failed at the runtime as

> a.out

fatal Fortran runtime error(t.f:36): Invalid descriptor
Abort(coredump)

This failure seems a regression after the merge of PR #164279. However, if I changed the LHS to be NOT polymorphic, it still fails the same.

It seems the "allocatable" property got lost through the pointer assignment in FORALL.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions