一个简单的代码:
program main
integer, allocatable :: A(:,:)
integer :: B(3,4)
B=1
A = B !A will get allocated, with the same shape and bounds as B
end program main使用:gfortran-8 -std=f2008 -fcheck=all -Wall -Wextra -fbounds-check -fimplicit-none array.f90编译上面的代码
我收到了以下警告:
Warning: ‘a.offset’ may be used uninitialized in this function Warning: ‘a.dim[0].lbound’ may be used uninitialized in this function Warning: ‘a.dim[0].ubound’ may be used uninitialized in this function [-Wmaybe-uninitialized]
有没有人知道我为什么收到这些警告?
发布于 2019-05-23 02:31:58
这是一个著名的GCC bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77504,已经在bugzilla (甚至是我自己)中报告了许多副本-参见副本部分了解其他化身。
据我所知,编译器生成的实际代码应该可以正常工作,这只是一个不正确的警告。正如史蒂夫在评论中指出的那样,使用-Wno-maybe-uninitialized来隐藏此警告。我也将它包含在我的构建脚本中。
https://stackoverflow.com/questions/56261880
复制相似问题