Converting FORTRAN to C
John Mackin
john at physiol.OZ
Sun Dec 30 19:45:10 AEST 1984
In article <435 at ukma.UUCP>, david at ukma.UUCP (David Herron, NPR Lover) writes:
> Any program that is referencing outside
> the bounds of an array is already broken, and should be shot on
> sight. :-) (unless it can give good reason for behaving in such a manner).
There is at least one excellent reason, commonly used in C, for referencing
beyond the bounds of an array. It is this:
#define ARRAYSIZE 200
type_t array[ARRAYSIZE];
...
type_t *p;
for (p = array; p < &array[ARRAYSIZE]; p++)
...
Now, sure you could say "p <= &array[ARRARYSIZE - 1]" instead. But which
is clearer, and easier to read ... and, more importantly, used in many,
many places in V7 UNIX as distributed by AT&T? I get VERY ANGRY at compilers
like Whitesmiths' (for VAX/VMS, at least) that get upset about this construct.
After all, this is C, not PASCAL or some other wimp's language that
checks array bounds. :-)
John Mackin, Physiology Department, University of Sydney, Sydney, Australia
...!decvax!mulga!physiol.su.oz!john
More information about the Comp.lang.c
mailing list