【发布时间】:2020-06-19 15:46:12
【问题描述】:
以下 Fortran 代码在 SLES 15 上使用 ifort 版本 19.0.3.199 编译时生成分段错误 (-O0):
program test_prg
call sub1()
contains
subroutine sub1(opt)
integer, allocatable, optional :: opt(:)
call sub2(opt)
end subroutine
subroutine sub2(opt)
integer, optional :: opt(:)
end subroutine
end program
我不打算在sub2 中分配opt,所以我没有在那里指定allocatable 属性。如果我让它在两个子例程中都可以分配或非可选,或者如果我在调用sub1 时传递一个实际参数,那么代码将完成而没有错误。当使用 gfortran 从 gcc 版本 8.3.0 20190222 编译时,相同的代码也可以正常运行。
这是编译器的错误还是我在这里做了非法的事情?
【问题讨论】:
标签: segmentation-fault fortran intel-fortran sles