Path: utzoo!yunexus!geac!daveb From: daveb@geac.UUCP (David Collier-Brown) Newsgroups: comp.lang.c Subject: Re: Is &a[NTHINGS] legal Summary: Well, yes, but it can be hard under some boundary conditions. Message-ID: <2699@geac.UUCP> Date: 5 May 88 12:45:20 GMT Article-I.D.: geac.2699 Posted: Thu May 5 08:45:20 1988 References: <12074@tut.cis.ohio-state.edu> <7806@brl-smoke.ARPA> <2637@ttrdc.UUCP> <1450@iscuva.ISCS.COM> Reply-To: daveb@geac.UUCP (David Collier-Brown) Organization: GEAC Computers, Toronto, CANADA Lines: 29 In article <1450@iscuva.ISCS.COM> carlp@iscuva.ISCS.COM (Carl Paukstis) writes: >The above notion follows from a quick reading of Mr. Gwyn's original >followup. It seems, however, that there need not be an addressable OBJECT >beyond the array bound, and it is an error to attempt to dereference >a[NTHINGS+1]. There must be a valid ADDRESS (or at least simulation of >one), so that size calculations will work, mostly, but also so that >bound-checking as proposed in the original posting is possible. My understanding is that one has to be able to generate the address of the last-plus-one'th element of an array: thing a[NTHINGS]; ... if (x < &a[NTHINGS]) ... I'm not so sure about NTHINGS+1, which is the last-plus-two'th (last-plus-tooth?) element. As you might expect, this reqirement identifies a problem with machines like the DPS-6, which will need the shim at &a[NTHINGS] to keep from trapping when the address is loaded into a register and checked for legality. --dave -- David Collier-Brown. {mnetor yunexus utgpu}!geac!daveb Geac Computers International Inc., | Computer Science loses its 350 Steelcase Road,Markham, Ontario, | memory (if not its mind) CANADA, L3R 1B3 (416) 475-0525 x3279 | every 6 months.