From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,583275b6950bf4e6 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-19 01:22:32 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!lnsnews.lns.cornell.edu!newsstand.cit.cornell.edu!ngpeer.news.aol.com!newsfeed1!bredband!uio.no!feed.news.nacamar.de!fu-berlin.de!uni-berlin.de!213.200.246.247!not-for-mail From: Vinzent Hoefler Newsgroups: comp.lang.ada Subject: Re: Quality systems (Was: Using Ada for device drivers? (Was: the Ada mandate, and why it collapsed and died)) Date: Mon, 19 May 2003 10:21:27 +0200 Organization: JeLlyFish software Message-ID: References: <9fa75d42.0305130543.60381450@posting.google.com> <254c16a.0305140549.3a87281b@posting.google.com> <9fa75d42.0305141747.5680c577@posting.google.com> <3ec4b1c9$1@news.wineasy.se> <9fa75d42.0305161748.1735fc32@posting.google.com> <4W%xa.28765$cK5.11964@nwrdny02.gnilink.net> NNTP-Posting-Host: 213.200.246.247 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: fu-berlin.de 1053332551 27800255 213.200.246.247 (16 [175126]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:37505 Date: 2003-05-19T10:21:27+02:00 List-Id: Hyman Rosen wrote: >Yes, so? The unsigned types are like Ada's modular types, >with explicitly defined wraparound semantics. Yes, but that ain't Ada. In Ada you have to exeplicitely tell the compiler that you really want to do it and leave the burden to implement it to the compiler (and that sometimes might be not that easy as it looks at the first glance). >I dare say >that if C had not had unsigned types, Ada would never have >gotten modular types. I doubt that. C just got modular types because it was convinient and natively supported by the machine. Disclaimer: I'm not old enough to know the PDP-7 by heart. ;) >>>It is perfectly >>>legal for an implementation to detect these and report an error. >>=20 >> And it will do only if the machine is "limited" this way. > >I'm sorry but I don't understand what that sentence means. >What machine? The underlying machine the code is compiled for. >What does limited mean, and why is it in scare quotes? "Limited" in the sense that it is not able to wrap around signed integers without signalling some overflow exception or similar. That's the one and only reason this "check" is permitted in C. Another reason is that there might be some machines that don't use the two's-complement, so the whole operation is simply undefined behaviour in that case. Or at least not that what you've expected. So in C the answer is simple: Don't overflow signed types, the result may not be defined. Nice try, but I wouldn't call that overflow *check*. Even if it *would* occur on some particular machine, you wouldn't be able to catch it at runtime (well, not with standard language features). >As far as I know, Ada and C can run on the same machines, so if Ada >can have overflow checks, C can too. No. In C you only get the overflow checks (for signed types) if the machine itself supports it. Otherwise you get a wonderful implementation defined (or whatever this is called) wraparound. And I know a lot of programmers who rely on this for the particular machine their code is running on ("Signed? Unsigned? Don't bother me, it's all the same bit pattern anyway."). Vinzent. --=20 Parents strongly cautioned -- this posting is intended for mature audiences over 18. It may contain some material that many parents would not find suitable for children and may include intense violence, sexual situations, coarse language and suggestive dialogue.