以下 Fortran 代码-O0
在 SLES 15 上使用 ifort 版本 19.0.3.199 编译时会产生分段错误,而无需优化 ( ):
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
我不打算在其中分配,所以我没有在那里指定opt
属性。如果我让它在两个子例程中都可以分配或非可选,或者如果我在调用中传递一个实际参数,则代码完成而不会出错。当使用 gfortran 从 gcc 版本 8.3.0 20190222 编译时,相同的代码也可以正常运行。sub2
allocatable
sub1
它是编译器错误还是我在这里做非法的事情?