Re: array operations on non-conforming arrays -- do compilers catch them?
- From: "Lane Straatman" <invalid@xxxxxxxxxxx>
- Date: Fri, 30 Mar 2007 20:23:25 -0400
"Beliavsky" <beliavsky@xxxxxxx> wrote in message
news:1175288168.015467.93880@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am finding that most Fortran 95 compilers do not catch, even at runIs it your intent to have the do loop go from n to n?
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
--
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 .
.
- Follow-Ups:
- References:
- Prev by Date: Re: Sample polling program code?
- Next by Date: Re: variable content lost
- Previous by thread: Re: array operations on non-conforming arrays -- do compilers catch them?
- Next by thread: Re: array operations on non-conforming arrays -- do compilers catch them?
- Index(es):
Relevant Pages
|