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,7be3870dd9c9518f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-15 11:05:37 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!ra.nrl.navy.mil!dca6-feed2.news.algx.net!allegiance!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: CONSTRAINT_ERROR - why? User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Sun, 15 Dec 2002 19:04:38 GMT Content-Type: text/plain; charset=us-ascii References: <3DFB7841.F898C02@t-online.de> <3%KK9.53003$vM1.4249406@bgtnsc04-news.ops.worldnet.att.net> <3DFB8495.A655C512@t-online.de> <616gta.hk3.ln@beastie.ix.netcom.com> <3DFC878D.B6966C37@t-online.de> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:31857 Date: 2002-12-15T19:04:38+00:00 List-Id: Alfred Hilscher writes: > Dennis Lee Bieber schrieb: > > > > From the user guide: > > > > -gnato > > Enables overflow checking for integer operations. This causes GNAT > > to generate slower and larger executable programs by adding code to > > check for overflow (resulting in raising Constraint_Error as required > > by standard Ada semantics). These overflow checks correspond to > > situations in which the true value of the result of an operation may be > > "... the result of an operation ..." The result of the operation "/" > _does_ fit into a BYTE. The Constraint_Error comes from the implicit conversion from universal integer to BYTE, which happens to the *operands* of "/". It's got nothing to do with the "/" itself. It's a Range_Check, by the way, not an Overflow_Check. I don't know if the -gnato switch understands that. The relevant RM paragraph is 4.6(28). It is a mistake, in my opinion (although I didn't realize it at the time). All the other operations on modular types wrap around -- clearly type conversion should work the same way. (Randy will say that *none* of the operations should wrap around, and I could go along with that, too. But have one "gotcha" operation work differently from all the rest is poor language design.) > > outside the base range of the result type. The following example shows > > the distinction: - Bob