Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!orchid!rbutterworth From: rbutterworth@orchid.UUCP Newsgroups: comp.lang.c Subject: Re: char (*a)[] (was: Style [++i vs i++]) Message-ID: <10758@orchid.waterloo.edu> Date: Sun, 20-Sep-87 11:39:15 EDT Article-I.D.: orchid.10758 Posted: Sun Sep 20 11:39:15 1987 Date-Received: Sun, 20-Sep-87 22:39:20 EDT References: <8298@brl-adm.ARPA> <587@cblpe.ATT.COM> <189@xyzzy.UUCP> <8655@mimsy.UUCP> Organization: U of Waterloo, Ontario Lines: 23 Keywords: brain dead architectures versus X3J11 In article <8655@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: > for (p = foo; p < &foo[10]; p++) > is portable, and compilers must allow for it, but > for (p = &foo[9]; p >= foo; p--) > is not, and compilers need not allow for it. This does not `break > half the code in existence' except when one tries to run it on an > architecture in which &foo[-1] >= &foo[0] (where---surprise!---it > already fails). Using for (p = &foo[9]; p != foo; p--) gets around this problem of the incorrect inequality. The question is, does an expression, such as "p--", that generates an illegal address violate the standard if that address is never used as an address? e.g. given "p = &foo[-1];", it is obviously wrong to use "*p", but is there hardware for which the assignment itself would cause a machine fault (assuming "p" is not declared as "register")? If there aren't any such machines, why does this assignment violate the ANSI standard?