array[-1] -- permitted?
Henry Spencer
henry at utzoo.uucp
Sun Sep 25 07:11:46 AEST 1988
In article <69575 at sun.uucp> swilson at sun.UUCP (Scott Wilson) writes:
>I'm not quite sure what is being discussed. I assume the standard
>says that the -1'th element on an array is not guaranteed to be
>accessible, not that negative array indices are disallowed...
More precisely, what it says is that even *computing* a pointer to the
-1th element of an array can send you off into the Twilight Zone. This
is not new -- if you read K&R, that's always been the rule. However,
there is no objection to subtracting 1 from a pointer that already points
to the Nth element of an array, where N > 0. (&a[1])[-1] is legal.
--
NASA is into artificial | Henry Spencer at U of Toronto Zoology
stupidity. - Jerry Pournelle | uunet!attcan!utzoo!henry henry at zoo.toronto.edu
More information about the Comp.lang.c
mailing list