Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-tis!ames!mailrus!husc6!XAIT!g-rh
From: g-rh@XAIT.XEROX.COM (Richard Harter)
Newsgroups: comp.lang.c
Subject: Re: Out of range pointers
Message-ID: <33598@XAIT.XEROX.COM>
Date: 21 Sep 88 07:30:05 GMT
References: <867@osupyr.mast.ohio-state.edu> <3200@geac.UUCP> <1430@ficc.uu.net> <1988Sep15.145026.20325@ateng.uucp> <16041@ism780c.isc.com> <8515@smoke.ARPA> <33432@cca.CCA.COM> <1988Sep19.213023.13181@utzoo.uucp> <33547@XAIT.XEROX.COM> <8544@smoke.ARPA>
Reply-To: g-rh@XAIT.Xerox.COM (Richard Harter)
Organization: Xerox Corporation, Cambridge, Massachusetts
Lines: 31

In article <8544@smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes:
>In article <33547@XAIT.XEROX.COM> g-rh@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.

>There is a considerable practical difference between this case and the
>one for a pointer just past the last member of an array.  The [-1] case
>can require reservation of an arbitrary amount of unused address space
>below an actual object, whereas the other case requires no more than a
>byte (or a word, depending on the architecture) of space reserved above.

Good point.  [For those who didn't catch it, the size of the object that
a pointer is pointing to can be a structure of (arbitrary) size.  To allow
&x[-1] to be legal you have to leave enough space for an instance of the
structure (or array of structures or whatever) before the actual instance.]

Doug's claim that the other case (one past) need only require a word (or byte)
of memory at the end suggests a question that I don't know the answer to.
Suppose that x is an array of structures of length n.  As we all know, 
&x[n] is legal.  But what about &x[n].item?  If Doug's assertion is correct,
and I expect it is since he is quite knowledgable in these matters, then
it would seem to follow that &x[n].item is not guaranteed to be legal.



-- 

In the fields of Hell where the grass grows high
Are the graves of dreams allowed to die.
	Richard Harter, SMDS  Inc.