This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Problems with intrinsic assignments of a derived type to an unlimited polymorphic
- From: Damian Rouson <damian at sourceryinstitute dot org>
- To: gfortran <fortran at gcc dot gnu dot org>
- Cc: "Clune, Thomas L. (GSFC-6101)" <thomas dot l dot clune at nasa dot gov>
- Date: Mon, 11 Nov 2019 20:12:02 -0800
- Subject: Problems with intrinsic assignments of a derived type to an unlimited polymorphic
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