[Bug fortran/37199] array assignment from function writes out of bounds
dominiq at lps dot ens dot fr
gcc-bugzilla@gcc.gnu.org
Fri Aug 22 10:57:00 GMT 2008
------- Comment #2 from dominiq at lps dot ens dot fr 2008-08-22 10:56 -------
Confirmed on i686-apple-darwin9 (both 32 and 64 bit modes). Compiling the test
with -fbounds-check gives at run time:
At line 18 of file pr37199.f90
Fortran runtime error: Array bound mismatch for dimension 1 of array 'pxq'
The modified test
program bounds_issue
implicit none
integer, parameter :: dp = kind(1.0d0)
real(dp), pointer :: pdf0(:,:), dpdf(:,:)
allocate(pdf0(0:282,-6:7))
allocate(dpdf(0:282,-6:7)) ! with dpdf(0:283,-6:7) [illegal] error
disappears
write(*,*) lbound(dpdf), ubound(dpdf)
pdf0 = 1.0d0
dpdf = 0.0d0
dpdf = tmp_PConv(pdf0)
if (any(dpdf /= pdf0)) call abort()
contains
function tmp_PConv(q_in) result(Pxq)
real(dp), intent(in) :: q_in(0:,-6:)
real(dp) :: Pxq(0:ubound(q_in,dim=1),-6:7)
Pxq = 0d0
write(*,*) lbound(q_in), ubound(q_in)
write(*,*) lbound(Pxq), ubound(Pxq)
Pxq = q_in
return
end function tmp_PConv
end program bounds_issue
gives at run time
0 -6 282 7
0 -6 282 7
0 -6 282 7
and does not abort, suggesting that the copy has been properly done. It looks
like as another "off by one" issue(?).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37199
More information about the Gcc-bugs
mailing list