[Bug fortran/82243] -fcheck=bounds not checking, and behaving differently with different real kinds
harper at msor dot vuw.ac.nz
gcc-bugzilla@gcc.gnu.org
Tue Sep 19 23:59:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82243
--- Comment #2 from harper at msor dot vuw.ac.nz ---
Since reporting the bug yesterday I have found that the bug requires the
integer n to be a subprogram argument. If instead n is a constant, the
bad array assignment is correctly diagnosed at compile time
even without -fcheck=bounds. Evidence:
cayley[~/Jfh] % cat gfbug7.f90
! array section assigned to wrong-shape array constructor in subroutine.
module globals
implicit none
integer,parameter:: n = 40, mp = kind(1d0)
contains
subroutine finds( s)
real(mp),intent(out)::s(0:)
real(mp),dimension(0:n/2+1):: even
integer:: i
even = 1.0_mp
s(0) = even(1)
s(2:n-1:2) = [(even(i),i=1,n/2)]
print *,'Sizes: LHS',size(s(2:n-1:2)),'RHS',size(even(1:n/2))
end subroutine finds
end module globals
program gfbug7
use globals, only: mp,n,finds
implicit none
real(mp),allocatable:: s(:)
allocate(s(0:n))
print *,merge('Single','Double',mp==kind(1.0))//' precision'
call finds(n,s)
print "(20F3.0)",s(0::2)
end program gfbug7
cayley[~/Jfh] % gf gfbug7.f90
gfbug7.f90:13:4:
s(2:n-1:2) = [(even(i),i=1,n/2)]
1
Error: Different shape for array assignment at (1) on dimension 1 (19 and
20)
gfbug7.f90:19:6:
use globals, only: mp,n,finds
1
Fatal Error: Can't open module file ‘globals.mod’ for reading at (1): No
such file or directory
compilation terminated.
cayley[~/Jfh] %
-- John Harper, School of Mathematics and Statistics
Victoria University, PO Box 600, Wellington 6140, New Zealand
e-mail john.harper@vuw.ac.nz phone (+64)(4)463 5276 fax (+64)(4)463 5045
---------- Forwarded message ----------
Date: Tue, 19 Sep 2017 22:47:42 +0000
From: dominiq at lps dot ens.fr <gcc-bugzilla@gcc.gnu.org>
To: John Harper <John.Harper@vuw.ac.nz>
Subject: [Bug fortran/82243] -fcheck=bounds not checking,
and behaving differently with different real kinds
Resent-Date: Wed, 20 Sep 2017 10:48:09 +1200 (NZST)
Resent-From: <john.harper@vuw.ac.nz>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82243
Dominique d'Humieres <dominiq at lps dot ens.fr> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-09-19
Ever confirmed|0 |1
--- Comment #1 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed. Related to/duplicate of pr31059?
More information about the Gcc-bugs
mailing list