This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

bounds cheking


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]