Problems with intrinsic assignments of a derived type to an unlimited polymorphic

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Problems with intrinsic assignments of a derived type to an unlimited polymorphic

Damian Rouson-4
All,

Compiling the program below with a GCC trunk build dated 20190926
produces an executable file that generates a segmentation fault at
runtime due to an invalid memory reference.  Would this be a duplicate
of PR 83118 if submitted?  Interestingly, removing the second
intrinsic assignment leads to an "undefined symbols" linker error.

Damian

  implicit none

  type Wrapper
    class(*), allocatable :: elements(:)
  end type

  class(*), allocatable :: obj
  type(Wrapper) w
  integer :: expected(1)=1

  w = new_wrapper(expected)
  obj = w  ! Runtime eg fault
  obj =  new_wrapper(expected) ! Linker error if above line is removed
contains
  type(Wrapper) function new_wrapper(array)
    class(*) array(:)
    new_wrapper%elements = array
  end function
end