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 Subject: Re: char (*a)[] (was: Style [++i vs i++]) Message-ID: <6448@brl-smoke.ARPA> Date: Sun, 20-Sep-87 22:02:31 EDT Article-I.D.: brl-smok.6448 Posted: Sun Sep 20 22:02:31 1987 Date-Received: Mon, 21-Sep-87 04:14:49 EDT References: <8298@brl-adm.ARPA> <587@cblpe.ATT.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 28 In article <2474@xanth.UUCP> kent@xanth.UUCP (Kent Paul Dolan) writes: >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. A pointer to the [-1]st element of an array may well have an address CONSIDERABLY smaller than that of the [0]th element, if the array elements are large. This is not a problem for the [N+1]st element. Therefore, there is only a small penalty in requiring implementations to ensure that [N+1] pointers have valid addresses (generally only wastes at most one word of "slop" space per segment), but there would be an unacceptably large penalty with requiring that a pointer to the [-1]st element of an array have a valid address. This was in fact discussed by X3J11 and general agreement reached to require [N+1] pointer validity, but not [-1] pointer validity. This permits one common form of somewhat sloppy coding, but not the other. Please note that the outlawed form was NEVER safe; I've seen it break in a PDP-11 implementation of bsearch() (due to data space address wrap-around), for example. It is not within X3J11's power to "somehow" make the unworkable work. And yes, please teach every C programmer in the world how to write reliable code. Thanks in advance.