A gfortran issue with parameterized derived types

@FortranFan out of curiosity I took your mwe and tested it with a couple of extra tweaks Compiler Explorer and saw that gfortran 14.1 now enables compiling and running this code. I do not know how far the bugs with PDTs have been improved, but this seems encouraging.

@han190 A slight modification of your code enables it to run with the latest gfortran:

program main
   use iso_fortran_env, only: real32
   implicit none

   type :: arr_o_rarr(k)
      integer, kind :: k
      real(k), allocatable :: arr(:)
   end type arr_o_rarr

   type(arr_o_rarr(real32)), allocatable :: arrs(:)
   integer :: i, j, dims

   dims = 10
   allocate (arrs(dims))
   do i = 1, dims
      allocate(arrs(i)%arr(i), source= [(j*1., j = 1, i)] ) !> this: "arrs(i)%arr = [(j*1., j = 1, i)]" produced a segfault
      print *, arrs(i)%arr
   end do
   
end program main
stdout with gfortran 14.1
Program stdout

   1.00000000    
   1.00000000       2.00000000    
   1.00000000       2.00000000       3.00000000    
   1.00000000       2.00000000       3.00000000       4.00000000    
   1.00000000       2.00000000       3.00000000       4.00000000       5.00000000    
   1.00000000       2.00000000       3.00000000       4.00000000       5.00000000       6.00000000    
   1.00000000       2.00000000       3.00000000       4.00000000       5.00000000       6.00000000       7.00000000    
   1.00000000       2.00000000       3.00000000       4.00000000       5.00000000       6.00000000       7.00000000       8.00000000    
   1.00000000       2.00000000       3.00000000       4.00000000       5.00000000       6.00000000       7.00000000       8.00000000       9.00000000    
   1.00000000       2.00000000       3.00000000       4.00000000       5.00000000       6.00000000       7.00000000       8.00000000       9.00000000       10.0000000    
2 Likes