[Bug middle-end/86437] New: runtime segfault on Fortran code with large array and -Ofast
janus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Jul 9 09:14:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86437
Bug ID: 86437
Summary: runtime segfault on Fortran code with large array and
-Ofast
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: janus at gcc dot gnu.org
Target Milestone: ---
Reduced test case:
program ACT
implicit none
integer, parameter :: N = 53, M = 20000
integer :: i
integer, dimension(1:2*N) :: list
real(8), dimension(:,:), allocatable :: Y1, Y2
do i=1,2*N
list(i) = min(i, N)
end do
call DoAllocate(Y1, 1,N, 1,M)
call DoAllocate(Y2, 1,2*N, 1,2*M)
call ArrayCopy(Y2(list(1:N),1:M), Y1)
contains
subroutine DoAllocate(a, l1, u1, l2, u2)
real(8), allocatable, intent(inout) :: a(:,:)
integer, intent(in) :: l1, u1, l2, u2
allocate(a(l1:u1,l2:u2), source=0.0_8)
end subroutine
subroutine ArrayCopy(arrFrom, arrTo)
real(8), dimension(:,:), intent(in) :: arrFrom
real(8), dimension(:,:), intent(inout) :: arrTo
arrTo(:,:) = arrFrom(:,:)
end subroutine
end
When compiling this with any recent gfortran version (4.7.x up to 9-trunk)
using -Ofast, I get a segfault at runtime.
Things that make the segfault disappear:
* using gfortran 4.6.4
* using smaller M (e.g. M=2000)
* using -O1, -O2 or -O3 (with these I can even make M much larger, e.g.
M=200000)
Since the optimization level changes the behavior crucially, I assume this is
more of a middle-end than a front-end issue.
More information about the Gcc-bugs
mailing list