[all-commits] [llvm/llvm-project] e89a00: [flang] Fix element indexing in Destroy component ...

Valentin Clement (バレンタイン クレメン) via All-commits all-commits at lists.llvm.org
Thu Feb 23 08:27:38 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e89a00db6d0596fe0263ca0a1052e5e6859744e9
      https://github.com/llvm/llvm-project/commit/e89a00db6d0596fe0263ca0a1052e5e6859744e9
  Author: Valentin Clement <clementval at gmail.com>
  Date:   2023-02-23 (Thu, 23 Feb 2023)

  Changed paths:
    M flang/runtime/derived.cpp

  Log Message:
  -----------
  [flang] Fix element indexing in Destroy component deallocation

Derived type `Destroy` function does not take step into consideration
when indexing the component element for deallocation. This leads to
incorrect deallocation in case like:

```
module mod1
  type :: t
    real, allocatable :: r(:)
  end type
contains
  subroutine do_smth(c)
    class(t), intent(out) :: c(:)
    do i = 1, size(c)
      if (allocated(c(i)%r)) then
        print*, i, 'not deallocated'
      end if
    end do
  end subroutine
end module

program test
  use mod1
  type(t) :: z(6)
  integer :: i
  do i = 1, 6
    Allocate(z(i)%r(i))
  end do
  call do_smth(z(::2))
end
```

Similar change was done in D142527

Reviewed By: klausler

Differential Revision: https://reviews.llvm.org/D144553




More information about the All-commits mailing list