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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4eca860272d4832b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!a34g2000cwb.googlegroups.com!not-for-mail From: Matt.Jaffe@gmail.com Newsgroups: comp.lang.ada Subject: Re: Static vs dynamic evaluation anomaly? Date: 7 Feb 2007 13:46:32 -0800 Organization: http://groups.google.com Message-ID: <1170884792.336164.308550@a34g2000cwb.googlegroups.com> References: <12shen4qjhv41a7@corp.supernews.com> <1170792077.235994.10900@q2g2000cwa.googlegroups.com> <87d54mguco.fsf@ludovic-brenta.org> <1170843700.7656.47.camel@localhost.localdomain> NNTP-Posting-Host: 204.75.207.169 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1170884808 27203 127.0.0.1 (7 Feb 2007 21:46:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 7 Feb 2007 21:46:48 +0000 (UTC) In-Reply-To: <1170843700.7656.47.camel@localhost.localdomain> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: a34g2000cwb.googlegroups.com; posting-host=204.75.207.169; posting-account=xQKYQw0AAAB-R-DTcooFOv7rzzyYco0o Xref: g2news2.google.com comp.lang.ada:9097 Date: 2007-02-07T13:46:32-08:00 List-Id: On Feb 7, 3:21 am, Georg Bauhaus wrote: > On Wed, 2007-02-07 at 11:00 +0100, Ludovic Brenta wrote: > > Steve writes: > > > Adam Beneschanwrote > > >> On Feb 6, 9:29 am, MattJaffewrote: > > > >> The following program produces incorrect results on GNAT, or at least > > >> on the version I'm using: > > > >> with Ada.Text_IO; > > >... > > >> end test271; > > > > One more data point... ObjectAda 7.2.2 gives the result: > > > > When J= 0, X*2**J = 31 > > > When J= 1, X*2**J = 62 > > > When J= 2, X*2**J = 60 > > > When J= 3, X*2**J = 56 > > > When J= 4, X*2**J = 48 > > > When J= 5, X*2**J = 32 > > > > Which I believe is correct, > > > Regards, > > > Actually I'll take back what I said earlier. With Debian gnat > > 4.1.1-22 I also get these seemingly correct results. > > It seems to depend on a compiler switch, could you try > > $ gnatmake -gnatp -s test271 > $ gnatmake -gnato -s test271 > > -- Georg You are correct; the anomaly does not appear when the -gnato option is used for the compilation. And since I have now looked up the significance of the -gnato option, I now know why; sort of. I am disturbed, however, in that the default (no overflow checking) allows the production and execution of code yielding what seem to me to be semantically invalid results. To allow the deliberately disabling, for performance reasons, of a feature that insures semantic compliance may be something that a compiler should allow to broaden its appeal; but to have default behavior that is not compliant with the language's semantics seems very odd to me. Or am I mis-interpreting the situation here?