I am trying to create a linked list with parameterized derived type, and here is a minimal example that triggers the error:
module module_utility
implicit none
type :: array_type(kind, len)
integer, kind :: kind
integer, len :: len
real(kind=kind) :: values(len)
end type array_type
type :: node_type(kind, len)
integer, kind :: kind
integer, len :: len
type(array_type(kind, len)) :: array
type(node_type(kind, len)), pointer :: next => null()
end type node_type
end module module_utility
program main
use iso_fortran_env, only: real32
use module_utility
implicit none
! type(node_type(kind=real32, len=10)) :: list
! It works
type(node_type(kind=real32, len=:)), allocatable :: list
! error #6147: The structure definition stack has been exceeded.
end program main
Both ifx
and ifort
throw me
error #6147: The structure definition stack has been exceeded.
Since it is not an ICE, I must be doing something wrong. What is the proper method for constructing a linked list type using PDT?