Array syntax



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
.



Relevant Pages

  • Re: Array syntax
    ... But after I turned on array bounds checking, the absoft compiler ... started printing warning messages for these zero size ranges. ... The value of MATMUL is defined in terms of SUM and that is defined to work for zero sized arrays. ...
    (comp.lang.fortran)
  • Re: Array syntax
    ... But after I turned on array bounds checking, the absoft compiler ... started printing warning messages for these zero size ranges. ...
    (comp.lang.fortran)
  • Re: D3/Linux compile question
    ... consider zero a valid array element while the Prime flavors do. ... 02 EQUATE ZERO TO ARRAY ... 07 CRT ARRAY ... Compiler catches line 6 and 13 as subscript out of range. ...
    (comp.databases.pick)
  • Re: D3/Linux compile question
    ... His secret was he started counting at zero. ... base frame not 1 past the base frame. ... I just give the compiler what it wants, ... As far as EQU VAR TO ARRAY(0), when we know the first index into ARRAY ...
    (comp.databases.pick)
  • Re: D3/Linux compile question
    ... consider zero a valid array element while the Prime flavors do. ... 02 EQUATE ZERO TO ARRAY ... 07 CRT ARRAY ... Compiler catches line 6 and 13 as subscript out of range. ...
    (comp.databases.pick)