Array syntax
- From: Ron Shepard <ron-shepard@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 17 Jun 2011 11:37:02 -0500
I'm debugging some code, so I turned on array bounds checking on my
compilers (gfortran, absoft, and ifort on MacOSX). I have some
array statements that look like this:
a(i:j) = a(i:j) + b(i:j)
....
a(i:j) = b(i:j) + matmul( c(i:j,m:n), d(m:n) )
These are inside nested do loops, and the various ranges i:j, m:n,
change within these loops. For some values of loop parameters these
ranges are zero size (e.g. 4:3). When this happens, nothing is
supposed to happen to the left hand sides of these assignments.
But after I turned on array bounds checking, the absoft compiler
started printing warning messages for these zero size ranges. I put
in the tests to avoid these statements in these cases, and I have
verified that this is NOT the bug that I'm chasing down.
But then I started wondering exactly when zero size ranges are
allowed to occur and when they aren't. I'm pretty sure that a zero
size i:j is allowed in the first expression above. Right? But what
about a zero size m:n and nonzero i:j in the second expression, or a
zero size i:j and a nonzero m:n?
Not only does it clutter my code to have these tests scattered
around, but if the language is going to do the tests anyway, then my
if-statements are redundant and just lead to extra overhead.
Is this a bug in my code, or is it a bug in the bounds checking code
generated by the absoft compiler?
$.02 -Ron Shepard
.
- Follow-Ups:
- Re: Array syntax
- From: Dick Hendrickson
- Re: Array syntax
- Prev by Date: Re: Recursive definition of (extensible) types
- Next by Date: Re: Array syntax
- Previous by thread: Recursive definition of (extensible) types
- Next by thread: Re: Array syntax
- Index(es):
Relevant Pages
|