A program compiled with gfortran terminates with a segmentation fault
at an intrinsic assignment to an allocatable array component of a
derived type with a kind type parameter. Please see below. I tried
several workarounds, including replacing the intrinsic assignment with
a type-bound defined assignment, a non-type-bound defined assignment,
and a source allocation. I also tried compiling code below with
gfortran 12, 13, and 14. The only workaround that eliminates the
segmentation fault is switching to source allocation. The code below
terminates normally with the NAG and LLVM Flang (Flang-new) compilers.
% cat reproducer.f90
implicit none
type foo_t(k)
integer, kind :: k
real(k), allocatable :: bar(:)
end type
type(foo_t(kind(0.))) foo
foo%bar = [0.]
end
% gfortran reproducer.f90
% ./a.out
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x102dfad2f
#1 0x102df9d83
#2 0x194afa583
#3 0x1027c7f4b
zsh: segmentation fault ./a.out
% gfortran --version
GNU Fortran (Homebrew GCC 14.1.0_2) 14.1.0