我想知道为什么这段代码在最后一次打印中返回错误。
使用 gfortran 7.4.0 失败,但使用 ifort 18.0.3 效果很好。
program test
implicit none
type :: syntax
integer, allocatable :: f(:)
end type
type(syntax), allocatable :: rhs(:)
allocate(rhs(2))
print*, allocated(rhs(2)%f)
print*, allocated(rhs(size(rhs))%f)
end program
gfortran 错误是:
F
Program received signal SIGSEGV: Segmentation fault - invalid memory reference.
Backtrace for this error:
#0 0x7f4cf40442da in ???
#1 0x7f4cf4043503 in ???
#2 0x7f4cf3c76f1f in ???
#3 0x55aa522e5e50 in test
at /home/pena/Escritorio/c.f90:10
#4 0x55aa522e5f0d in main
at /home/pena/Escritorio/c.f90:11
Violación de segmento (`core' generado)