[Bug fortran/98573] Dynamic type lost on assignment

davidhneill at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jan 6 19:12:44 GMT 2021


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

--- Comment #1 from David Neill Asanza <davidhneill at gmail dot com> ---
Removing the derived type container triggers a segfault.

$ cat segfault.f90

module foo
contains
  subroutine store1(arr, val)
    class(*), allocatable, intent(out) :: arr(:)
    class(*), intent(in) :: val(:)
    arr = val
  end subroutine store1
  subroutine store2(arr, val)
    class(*), allocatable, intent(out) :: arr(:)
    class(*), intent(in) :: val(:)
    allocate(arr, source=val)
  end subroutine store2
end module foo

program prog
  use foo
  class(*), allocatable :: arr(:)
  call store1(arr, [1, 2, 3])  ! SEGFAULT
  call store2(arr, [1, 2, 3])  ! NO PROBLEM
end program


$ gfortran -g -Wall -Wextra minimal.f90
$ ./a.out

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.


More information about the Gcc-bugs mailing list