Re: array operations on non-conforming arrays -- do compilers catch them?
- From: Bart Vandewoestyne <MyFirstName.MyLastName@xxxxxxxxxx>
- Date: Fri, 30 Mar 2007 21:13:20 GMT
On 2007-03-30, Beliavsky <beliavsky@xxxxxxx> wrote:
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 .
NAGWare Fortran 95 compiler Release 5.1(282) on Intel Linux and with
the -C=all option gives the following error at runtime:
Rank 1 of IVEC(1:I) has extent 3 instead of 2
Program terminated by fatal error
Aborted
Kind regards,
Bart
--
"Share what you know. Learn what you don't."
.
- References:
- Prev by Date: Re: undefined variable problem
- Next by Date: variable content lost
- Previous by thread: 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
|
|