Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Out of range pointers Message-ID: <1988Sep24.212050.26547@utzoo.uucp> Organization: U of Toronto Zoology 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> <1988Sep21.163915.19848@utzoo.uucp> <1988Sep23.141042.23951@sq.uucp> Date: Sat, 24 Sep 88 21:20:50 GMT In article <1988Sep23.141042.23951@sq.uucp> msb@sq.com (Mark Brader) writes: >Henry Spencer (henry@utzoo.uucp), no less, replies: >> The situation unfortunately isn't as symmetrical as it looks, because >> a pointer to an array element points to the *beginning* of the array >> element. > >He must not have gotten over his cold yet. The correct statement is: >a pointer to an array element *is typically implemented as* pointing to >the beginning of the array element... Mark, you might be surprised if you study the X3J11 drafts very closely. Remember, for example, that a pointer to a struct, suitably cast, is *required* to point to its first member. Okay, you can say that the cast can involve a conversion... but when you pay careful attention to the rules about pointers to unions, such schemes start coming unravelled. When you look very carefully at the combination of the rules for pointers to structs, pointers to unions, pointers to arrays whose members are also arrays, compatibility across separately-compiled modules, etc., it's very hard to do seriously unorthodox things with pointers without breaking a rule somewhere. -- NASA is into artificial | Henry Spencer at U of Toronto Zoology stupidity. - Jerry Pournelle | uunet!attcan!utzoo!henry henry@zoo.toronto.edu