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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,25aa3c7e1b59f7b5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-01-11 08:46:46 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsgate.cistron.nl!news2.euro.net!uunet!ash.uu.net!spool0900.news.uu.net!reader0900.news.uu.net!not-for-mail Message-ID: <3C3F1738.2020704@mail.com> Date: Fri, 11 Jan 2002 11:47:52 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:0.9.7+) Gecko/20010929 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: A case where Ada defaults to unsafe? References: <3C39E62F.3020504@look.ca> <3C39E726.8000408@mail.com> <87advpdi0f.fsf@chiark.greenend.org.uk> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Cache-Post-Path: master.nyc.kbcfp.com!unknown@mosquito.nyc.kbcfp.com X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1010767602 reader0.ash.ops.us.uu.net 8341 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:18778 Date: 2002-01-11T11:47:52-05:00 List-Id: Robert A Duff wrote: > Matthew Woodcraft writes: >>Doesn't RM 11.6 allow the compiler to ignore this exception? > > The compiler is always allowed to get the right answer instead of > overflowing. But I don't think that rule is stated in 11.6 -- somewhere > in chap 3 or 4, I think. > > But replace "x + y < 4" with something that fails in some other way (not > overflow). For example, "Integer'(x+y) < 4" must fail if x+y is out of > bounds. Here's what 11.6 says: An implementation need not always raise an exception when a language-defined check fails. Instead, the operation that failed the check can simply yield an undefined result. The exception need be raised by the implementation only if, in the absence of raising it, the value of this undefined result would have some effect on the external interactions of the program. So it seems to me that the case of if FALSE and Integer'(x+y) < 4 is also allowed not raise an overflow exception. I think that the compiler is allowed to short-circuit boolean expressions as long as doing so doesn't bypass any external interactions. I guess a similar result applies to 0 * (x + y) which is optimizable to 0 without coding an overflow check.