Out of range pointers
News system
news at ism780c.isc.com
Thu Sep 22 07:19:57 AEST 1988
In article <33547 at XAIT.XEROX.COM> g-rh at XAIT.Xerox.COM (Richard Harter) writes:
>
>As a side note, one argument for making x[-1] legal is that it permits
>you to use sentinels in both directions. I don't see that this is a
>problem, regardless of architecture. All that is required is that nothing
>be allocated on a segment boundary. However, as the man says, they way
>it is is the way it is. There never was a machine, a language, or an
>operating system without arcane restrictions. [Except lisp :-)]
>--
Consider:
some_big_type x[2];
If sizeof(some_big_type) is half the size of a segement, computing &x[-1] is
no harder (or easier) than computing &x[2]. The standard mandates that
&x[2] be computable but it does not mandate that &x[-1] be computable. I
suspect that a C implementation that allows arrays as large as large as a
segment is able to compute both addresses.
Note, mandating that &x[-1] be computable does not mean that x[-1] is
referencable. So evenif &x[-1] were computable we still could not have a
sentinel at the low end of the array. A sentinal at the low end is easy.
just start the data with x[1].
Marv Rubinstein
More information about the Comp.lang.c
mailing list