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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.172.129 with SMTP id l1mr34814143qaz.4.1373708240332; Sat, 13 Jul 2013 02:37:20 -0700 (PDT) X-Received: by 10.49.48.201 with SMTP id o9mr1467341qen.42.1373708240300; Sat, 13 Jul 2013 02:37:20 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder02.blueworldhosting.com!news.glorb.com!t19no1447154qam.0!news-out.google.com!f7ni2314qai.0!nntp.google.com!t19no1447151qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 13 Jul 2013 02:37:20 -0700 (PDT) In-Reply-To: <74c64a2c-f062-4b59-aafb-40c0bac39203@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=79.195.170.40; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 79.195.170.40 References: <74c64a2c-f062-4b59-aafb-40c0bac39203@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <151a6f74-9100-49dc-8c0c-f656aed1d7ea@googlegroups.com> Subject: Re: GNAT does not consistently raise an exception to log(0.0) From: AdaMagica Injection-Date: Sat, 13 Jul 2013 09:37:20 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:16343 Date: 2013-07-13T02:37:20-07:00 List-Id: On Saturday, July 13, 2013 2:52:08 AM UTC+2, Jerry wrote: > with Ada.Numerics.Long_Elementary_Functions; > use Ada.Numerics.Long_Elementary_Functions; > procedure Bomb_Log is > x : Long_Float; > begin > x := log(0.0); > end Bomb_Log; > > However, under the same conditions as above, the following program raises the exception always: > > with Ada.Numerics.Long_Elementary_Functions; > use Ada.Numerics.Long_Elementary_Functions; > with Ada.Text_IO; > use Ada.Text_IO; > procedure Bomb_Log is > x : Long_Float; > begin > x := log(0.0); > Put_Line(Long_Float'Image(x)); > end Bomb_Log; That's easy. In the first version, the compiler optimizes X away, since it's not used for any external effects. In the second version, you output an invalid value. See RM on allowed optimizations.