This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
bounds cheking
- From: "Benjamin Réveillé" <benjamin dot reveille at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Date: Tue, 6 Jun 2006 16:18:26 +0200
- Subject: bounds cheking
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=r31DDxGPg56MNZioTX7aysv7YRO/f8poaCbCng+kdYDib1WbXYs6SuF17grxkmpSJbwcbCMJaUYBBQ6uMzXqW+NBC8cFGr7GRAsND8fGCvMk7a5v8Z6+DRo17Y3N0hEiqHdd8QBrYNJ1hY9HW5Ta13V69N6d1QFD67WZeavlR0g=
Playing around with bounds checking on 4 compilers (including
gfortran, I have found a case where 2 act one way and 2 the oppposite
way...
Consider:
cat bounds.f90
program bounds
implicit none
integer, dimension(:), allocatable :: tabs,tabl
!
allocate(tabs(1),tabl(2))
tabl=0
tabs=tabl
print*,'SUCCES'
end program bound
gfortran (-g -fbounds-check) and xl (-g -C) find a out of bounds for
line tabs=tabl
So I guess they are trying to do
tabs(1:2)=tabl(1:2) and see that tabs(2) is out of bounds
gfortran says "Fortran runtime error: Array bound mismatch, size
mismatch for dimension 1 of array 'tabs' (in file 'bounds.f90', at
line 7)"
whereas pgf90 (-g -Mbounds) and ifort (-g -C) print SUCCES
So I guess they are trying to do
tabs(1:1)=tab(1:1) or else they just don"t see that tabs(2) is out of
bounds... and are squashing memory at tabs(2)
Who is right who is wrong (maybe they are both right/wrong) Any light
on the issue would be very much appreciated... (I personnaly think
that this is dirty coding... and like the fact that gfortran catches
it :) )
Thanks
Benjamin
P.S.
This variant has the same behavior as the original:
cat bounds2.f90
program bounds2
implicit none
integer :: d1,d2
integer, dimension(:), allocatable :: tabs,tabl
!
d1=1
d2=2
allocate(tabs(d1),tabl(d2))
tabl(:)=0
tabs(1:d1)=tabl(1:d2)
tabs(:)=tabl(:)
print*,'SUCCES'
end program bounds2