Contiguous Arrays

Henry Spencer henry at utzoo.uucp
Fri Feb 24 02:57:15 AEST 1989


In article <1831 at valhalla.ee.rochester.edu> badri at valhalla.ee.rochester.edu (Badri Lokanathan) writes:
>My argument is, since x is an independent variable (a pointer, but
>still a variable,) there is no way of checking any array bounds.
>Thus in order for consistency with the definition of pointer
>arithmetic,
>x -= i; x += i;
>should result in the original value of x (provided the resulting
>intermediate values are within pointer ranges.)

Exactly -- provided the intermediate values do not cause an overflow.
ON SOME MACHINES THEY CAN.  It is not true that all machines have a
single linear homogenous address space.  Some have it broken up into
pieces, and bad things can happen if your pointer arithmetic goes over
the edge of a piece.

>Further, the + and - operations group left to right and are
>associative...

In the absence of overflow.
-- 
The Earth is our mother;       |     Henry Spencer at U of Toronto Zoology
our nine months are up.        | uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list