Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!mandrill!hal!ncoast!allbery From: allbery@ncoast.UUCP Newsgroups: comp.lang.c,comp.unix.wizards Subject: Re: pointer alignment when int != char * Message-ID: <4287@ncoast.UUCP> Date: Sun, 30-Aug-87 11:04:55 EDT Article-I.D.: ncoast.4287 Posted: Sun Aug 30 11:04:55 1987 Date-Received: Tue, 1-Sep-87 00:39:53 EDT References: <493@its63b.ed.ac.uk> <6061@brl-smoke.ARPA> <3812@spool.WISC.EDU> <483@mtxinu.UUCP> <572@l.cc.purdue.edu> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: comp.lang.c Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 31 Xref: utgpu comp.lang.c:3893 comp.unix.wizards:3710 As quoted from <572@l.cc.purdue.edu> by cik@l.cc.purdue.edu (Herman Rubin): +--------------- | In article <483@mtxinu.UUCP>, ed@mtxinu.UUCP (Ed Gould) writes: | | > It's also not legal in the proposed ANSI C standard. Pointers | > may be subtracted *only* if they point to members of the same | > array of elements. | | The fact that some `gurus' cannot see the uses of this construct, as well | as others such as goto's, forcing inline, etc., is no more appropriate | than prohibiting the use of any tools developed since 1800 to sculptors. +--------------- Sure -- but, while your program may work fine on a Vax or a Sun, will it work on a Cray-1? LLNL's S-1? The ANSI C standard defines *portable* code; you can code something that works on your machine but doesn't conform, but don't expect it to work on every machine. (Example: the difference between two pointers not both associated with the same array may be meaningless on a tagged architecture, and may result in either a garbage result or a memory fault.) Subtracting pointers is a different kind of restriction from the use of "goto"; the latter is a *stylistic* restriction, the former is a *portability* restriction. -- Brandon S. Allbery, moderator of comp.sources.misc {{harvard,mit-eddie}!necntc,well!hoptoad,sun!mandrill!hal}!ncoast!allbery ARPA: necntc!ncoast!allbery@harvard.harvard.edu Fido: 157/502 MCI: BALLBERY <> ** Site "cwruecmp" has changed its name to "mandrill". Please re-address ** *** all mail to ncoast to pass through "mandrill" instead of "cwruecmp". ***