【发布时间】:2019-11-06 15:26:51
【问题描述】:
我想知道为什么这段代码在上次打印时返回错误。
使用 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)
【问题讨论】:
-
@francescalus 我刚刚在帖子中包含了错误。
-
ifort 的结果是什么?在 2 个打印语句
print *, size(rhs)之间放置时打印的内容。使用 gfortran 7.3.0 (Cygwin) 我得到F2T。 -
@albert ifort给出的解决方案是:F F
标签: fortran gfortran allocatable-array