Re: array operations on non-conforming arrays -- do compilers catch them?




"Beliavsky" <beliavsky@xxxxxxx> wrote in message
news:1175288168.015467.93880@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am finding that most Fortran 95 compilers do not catch, even at run
time, many invalid uses of non-conforming arrays when array subscripts
are variables. For the following invalid code,

program xsum_nonconform
integer, parameter :: n = 3
integer :: i,ivec(n)
ivec = 1
do i=n,n
print*,ivec(1:n-1) + ivec(1:i)
end do
end program xsum_nonconform
Is it your intent to have the do loop go from n to n?
--
LS


G95, Intel Visual Fortran, and Salford don't detect a problem at
compile or run time, but gfortran -fbounds-check says

Fortran runtime error: Array bound mismatch, size mismatch for
dimension 1 of array 'ivec' (in file 'xsum_nonconform.f90', at line 6)

and Lahey/Fujitsu with -chk says something similar.

I discovered such a bug in my production code using the new Gfortran
windows binary, dated 2007-03-29 .



.



Relevant Pages

  • Re: array operations on non-conforming arrays -- do compilers catch them?
    ... many invalid uses of non-conforming arrays when array subscripts ... For the following invalid code, ... G95, Intel Visual Fortran, and Salford don't detect a problem at ... Array bound mismatch, ...
    (comp.lang.fortran)
  • Re: Why no compiler-warning at invalid array-initializing ?
    ... Isn't it very easy for the compiler to detect this ... of invalid code because it uses an separate thread to ... monitor the array for null and eventualy prefilling the ... isn't a compile-time error because the int[] doesn't have a size, ...
    (comp.lang.java.programmer)
  • Re: intrinsics performance
    ... intrinsic functions and things like ... U = a*U (where U is an array). ... In order to beat the code generated by any recent gfortran dot_product, you must write more complicated source code, dealing with hardware-specific issues. ... So it's not a simple question of array assignments vs BLAS. ...
    (comp.lang.fortran)
  • Re: intrinsics performance
    ... intrinsic functions and things like ... In order to beat the code generated by any recent gfortran dot_product, you must write more complicated source code, dealing with hardware-specific issues. ... There, however, the question of a temporary array generated by f90 syntax may enter in. ... So it's not a simple question of array assignments vs BLAS. ...
    (comp.lang.fortran)
  • Re: ordering integer array
    ... required to be a rank 1 array rather than a scalar. ... but this seems to fit the bill for gfortran: ... Hex CA sounds like a leftover from the zipcode sort. ... Wealth - any income that is at least one hundred dollars more a year than ...
    (comp.lang.fortran)