comp.lang.ada
 help / color / mirror / Atom feed
From: Jerry <lanceboyle@qwest.net>
Subject: Odd overflow exception being raised in one-line program
Date: Tue, 29 Jan 2013 19:49:10 -0800 (PST)
Date: 2013-01-29T19:49:10-08:00	[thread overview]
Message-ID: <8259d65f-4b81-49d2-b1a0-613072c6b0fe@googlegroups.com> (raw)

A user of the PLplot plotting package, using Ada bindings, has reported an overflow exception that has not occurred before. He reports using Fedora rawhide which uses gcc 4.8. He reported the conditions surrounding the exception and I used that to make the following program and asked him to report his 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 := 0.3;
begin
   Put_Line("Running....");
   r := 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 binding in its present form has compiled on presumably numerous other systems, including those of other developers, without this problem. The PLplot user also 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 check failed" exception. In every case, the indicated line contains a conversion from Long_Float to Integer using the Integer( ) function with a Long_Float argument. It appears very likely that the exception is happening at every attempt to make such a conversion.

What am I missing here?

Jerry



             reply	other threads:[~2013-01-30  3:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-30  3:49 Jerry [this message]
2013-01-30 10:15 ` Odd overflow exception being raised in one-line program Simon Wright
2013-01-30 23:37 ` Randy Brukardt
2013-01-31  7:37 ` Jerry
2013-01-31 20:44   ` Simon Wright
2013-02-01  3:25   ` Jerry
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox