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-Thread: 103376,e387f06de055df74,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.66.86.137 with SMTP id p9mr316867paz.37.1359517751368; Tue, 29 Jan 2013 19:49:11 -0800 (PST) X-Received: by 10.50.149.234 with SMTP id ud10mr527804igb.11.1359517751290; Tue, 29 Jan 2013 19:49:11 -0800 (PST) Path: 6ni24044pbd.1!nntp.google.com!ld4no1972410pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 29 Jan 2013 19:49:10 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=97.117.196.239; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG NNTP-Posting-Host: 97.117.196.239 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8259d65f-4b81-49d2-b1a0-613072c6b0fe@googlegroups.com> Subject: Odd overflow exception being raised in one-line program From: Jerry Injection-Date: Wed, 30 Jan 2013 03:49:11 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2013-01-29T19:49:10-08:00 List-Id: A user of the PLplot plotting package, using Ada bindings, has reported an = overflow exception that has not occurred before. He reports using Fedora ra= whide which uses gcc 4.8. He reported the conditions surrounding the except= ion and I used that to make the following program and asked him to report h= is results. Line 7 of the below program mimics a line in the Ada binding to= which his exception points. The program: with Ada.Text_IO; use Ada.Text_IO; procedure Test_Overflow is r : Integer; r1 : Long_Float :=3D 0.3; begin Put_Line("Running...."); r :=3D Integer((r1 * 255.001) - 0.499999999999999); end Test_Overflow; His results: [orion@vmrawhide ~]$ gnatmake Test_Overflow.adb gcc -c Test_Overflow.adb Test_Overflow.adb:2:11: warning: file name does not match unit name, should= be "test_overflow.adb" gnatbind -x Test_Overflow.ali gnatlink Test_Overflow.ali [orion@vmrawhide ~]$ ./Test_Overflow Running.... raised CONSTRAINT_ERROR : Test_Overflow.adb:7 overflow check failed Just for kicks I had him run it with -gnato and he got the same results. This runs fine on my OS X 10.7.5 running GPL 2011 (20110419). The Ada bindi= ng in its present form has compiled on presumably numerous other systems, i= ncluding those of other developers, without this problem. The PLplot user a= lso reports several other overflow exceptions, all in a code base that has = never had such problems before. I investigated other places (18 total) where he is getting an "overflow che= ck failed" exception. In every case, the indicated line contains a conversi= on from Long_Float to Integer using the Integer( ) function with a Long_Flo= at argument. It appears very likely that the exception is happening at ever= y attempt to make such a conversion. What am I missing here? Jerry