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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.172.129 with SMTP id l1mr38705409qaz.4.1373773468719; Sat, 13 Jul 2013 20:44:28 -0700 (PDT) X-Received: by 10.50.120.8 with SMTP id ky8mr532807igb.11.1373773468565; Sat, 13 Jul 2013 20:44:28 -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!feeder01.blueworldhosting.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!t19no1534454qam.0!news-out.google.com!f7ni2314qai.0!nntp.google.com!t19no1534445qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 13 Jul 2013 20:44:28 -0700 (PDT) In-Reply-To: <151a6f74-9100-49dc-8c0c-f656aed1d7ea@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=97.117.199.112; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG NNTP-Posting-Host: 97.117.199.112 References: <74c64a2c-f062-4b59-aafb-40c0bac39203@googlegroups.com> <151a6f74-9100-49dc-8c0c-f656aed1d7ea@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: GNAT does not consistently raise an exception to log(0.0) From: Jerry Injection-Date: Sun, 14 Jul 2013 03:44:28 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 2479 Xref: news.eternal-september.org comp.lang.ada:16349 Date: 2013-07-13T20:44:28-07:00 List-Id: On Saturday, July 13, 2013 2:37:20 AM UTC-7, AdaMagica wrote: > 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. Yes, as Simon has also shown with the generated code differences. > > In the second version, you output an invalid value. No--I only attempt to output an invalid value. The Put_Line is never executed because the exception is raised before that, at the log(0.0) level. > See RM on allowed optimizations. I suppose that would be 11.6(5): http://www.adaic.org/resources/add_content/standards/12rm/html/RM-11-6.html Jerry