Path: utzoo!attcan!uunet!lll-winken!ames!oliveb!apple!rutgers!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Contiguous Arrays Message-ID: <9718@smoke.BRL.MIL> Date: 26 Feb 89 02:08:49 GMT References: <2508@ssc-vax.UUCP> <8943@alice.UUCP> <1828@valhalla.ee.rochester.edu> <7799@sneaky.TANDY.COM> <7309@killer.DALLAS.TX.US> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 35 In article <7309@killer.DALLAS.TX.US> chasm@killer.DALLAS.TX.US (Charles Marslett) writes: >This is not necessarily a condemnation of any computer that shows such lack >of concern for basic mathematics, but I would expect a computer that does >anything but return equality in the above expression to be broken as a >mathematical engine. If it is acceptable for addition and subtraction to >be other than inverse operations (taking into account the possibility of >an error trap or whatever) the thing you are using cannot support any >programming language I know of without simulating integer arithmetic with >some well protected external unit. First of all, you're wrong. The problem with out-of-range pointer arithmetic arises from the way that addresses have to be represented in a segmented architecture: a (segment identifier, offset) pair. Any arithmetic that would result in an out-of-segment address is simply illegal; anything could happen, including hardware trap of the illegal operation. However, in-range address computation presents no problem. I know of no Algol-like programming language that guarantees the ability to compute out-of-range pointers even as an intermediate step in a longer computation, probably because such a guarantee would severely constrain implementations on some architectures, requiring considerably less efficient data representations and generated code. Secondly, no computer fully supports the kind of real-number arithmetic (including integer arithmetic) that you were taught in school. Instead of saying that therefore all computers are broken, which is not helpful, most of us learn how to remain within the range of validity of actual hardware operations. The proposed C Standard makes explicit what is guaranteed here, and it does not constrain the programmer any more than the facts of reality already do. Out-of-range address computation causes trouble sooner or later; I've seen many examples of that already. >To make it even more serious, I do not know of any twos- >complement computer that even has a signed vs. unsigned add instruction. They are one and the same.