考虑下面的小程序,它重现了我在 mac os 上使用 gfortran gcc 9.2.0 时遇到的分段错误):
module stringmod
type :: str_t
character(len=:), allocatable :: s
contains
final :: finalize
end type str_t
type :: static_t
type(str_t) :: expr(3)
end type static_t
type :: dynamic_t
type(str_t), allocatable :: expr(:)
end type dynamic_t
contains
subroutine finalize ( x )
type(str_t), intent(in out) :: x
if (allocated(x%s)) deallocate(x%s)
end subroutine finalize
end module stringmod
use stringmod
implicit none
type(static_t ), allocatable :: stat(:)
type(dynamic_t), allocatable :: dyna(:)
integer :: i, j, …Run Code Online (Sandbox Code Playgroud)