Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c,comp.unix.wizards Subject: Re: pointer alignment when int != char * Message-ID: <6357@brl-smoke.ARPA> Date: Sat, 29-Aug-87 04:03:03 EDT Article-I.D.: brl-smok.6357 Posted: Sat Aug 29 04:03:03 1987 Date-Received: Sun, 30-Aug-87 07:40:52 EDT References: <493@its63b.ed.ac.uk> <6061@brl-smoke.ARPA> <3812@spool.WISC.EDU> <2130@umn-cs.UUCP> Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 15 Xref: mnetor comp.lang.c:4019 comp.unix.wizards:3968 In article <2130@umn-cs.UUCP>, randy@umn-cs.UUCP (Randy Orrison) writes: > In article <483@mtxinu.UUCP> ed@mtxinu.UUCP (Ed Gould) writes: > >Pointers may be subtracted *only* if they point to members of the same > >array of elements. > How is this determined? example: > strlen(s) > return (c-s); Obviously all characters in a string are in the same object (be it (char []) or chunk of malloc()-allocated storage. I don't recall if the latter is covered by the draft proposed standard but it should be. If some code violates the same-aggregate pointer constraint, the behavior is unspecified. It might work or it might not. No portable program should violate the constraint.