Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!cmcl2!brl-adm!umd5!mimsy!chris From: chris@mimsy.UUCP Newsgroups: comp.lang.c Subject: Re: char (*a)[] (was: Style [++i vs i++]) Message-ID: <8655@mimsy.UUCP> Date: Sat, 19-Sep-87 18:50:26 EDT Article-I.D.: mimsy.8655 Posted: Sat Sep 19 18:50:26 1987 Date-Received: Sun, 20-Sep-87 16:22:35 EDT References: <8298@brl-adm.ARPA> <587@cblpe.ATT.COM> <189@xyzzy.UUCP> <2474@xanth.UUCP> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 29 Keywords: brain dead architectures versus X3J11 >> for( p = &foo[9]; p >= foo; --p ){ /* loops forever */ In article <2474@xanth.UUCP> kent@xanth.UUCP (Kent Paul Dolan) writes: >I love it! > >OK, X3J11, the ball's in your court. Do we teach every C programmer >on every architecture in the world that decrementing pointer loops are >a no-no, and break half the code in existance, or do we finally bite >the bullet and decide that compiler writers for brain dead >architectures, and not the whole C community, pay the penalty for bad >hardware designs? Especially since these folks are often the >perpetrators of the bad hardware design. Unfortunately for you, it has already been considered, and the answer is that 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). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris