array operations on non-conforming arrays -- do compilers catch them?
- From: "Beliavsky" <beliavsky@xxxxxxx>
- Date: 30 Mar 2007 13:56:08 -0700
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
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 .
.
- Follow-Ups:
- Re: array operations on non-conforming arrays -- do compilers catch them?
- From: Lane Straatman
- Re: array operations on non-conforming arrays -- do compilers catch them?
- From: Bart Vandewoestyne
- Re: array operations on non-conforming arrays -- do compilers catch them?
- Prev by Date: Re: Sample polling program code?
- Next by Date: Re: undefined variable problem
- Previous by thread: Re: Sample polling program code?
- Next by thread: Re: array operations on non-conforming arrays -- do compilers catch them?
- Index(es):
Relevant Pages
|
|