comp.lang.ada
 help / color / mirror / Atom feed
* Odd overflow exception being raised in one-line program
@ 2013-01-30  3:49 Jerry
  2013-01-30 10:15 ` Simon Wright
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jerry @ 2013-01-30  3:49 UTC (permalink / 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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Odd overflow exception being raised in one-line program
  2013-01-30  3:49 Odd overflow exception being raised in one-line program Jerry
@ 2013-01-30 10:15 ` Simon Wright
  2013-01-30 23:37 ` Randy Brukardt
  2013-01-31  7:37 ` Jerry
  2 siblings, 0 replies; 6+ messages in thread
From: Simon Wright @ 2013-01-30 10:15 UTC (permalink / raw)


Jerry <lanceboyle@qwest.net> writes:

> 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.

>    r := Integer((r1 * 255.001) - 0.499999999999999);

> raised CONSTRAINT_ERROR : Test_Overflow.adb:7 overflow check failed

> 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?

Well, GCC 4.8 hasn't been released yet! but a quick check through the
bugs/regressions doesn't show anything like this. Let's hope it doesn't
make it to the release ..

Neither GCC 4.7.0 nor GNAT GPL 2012 shows the problem.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Odd overflow exception being raised in one-line program
  2013-01-30  3:49 Odd overflow exception being raised in one-line program Jerry
  2013-01-30 10:15 ` Simon Wright
@ 2013-01-30 23:37 ` Randy Brukardt
  2013-01-31  7:37 ` Jerry
  2 siblings, 0 replies; 6+ messages in thread
From: Randy Brukardt @ 2013-01-30 23:37 UTC (permalink / raw)


"Jerry" <lanceboyle@qwest.net> wrote in message 
news:8259d65f-4b81-49d2-b1a0-613072c6b0fe@googlegroups.com...
...
>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 wonder if his hardware (you didn't say what processor/OS the person with 
the problem is running on) is either setting some bit incorrectly, or the 
bit is being interpreted wrong. I saw something like this when we 
implemented hardware conversions in Janus/Ada, as some weird bits were 
getting set that we misinterpreted as an error. It's possible to set up the 
Intel hardware to trap, and that could happen for underflow and other 
loss-of-precision cases, and such a trap would probably get reported as an 
overflow error.

It even possible that his OS has left some goofy setup in the floating point 
unit which causes bogus traps (bad device driver?). Did he try rebooting 
and/or running a "clean" system?

                                           Randy.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Odd overflow exception being raised in one-line program
  2013-01-30  3:49 Odd overflow exception being raised in one-line program Jerry
  2013-01-30 10:15 ` 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
  2 siblings, 2 replies; 6+ messages in thread
From: Jerry @ 2013-01-31  7:37 UTC (permalink / raw)


Thanks for the comments, guys. Randy: I mentioned that the user with the problem is on Fedora Rawhide. Simon: Thanks for checking some other compilers.

I'll report back to the user and I guess tell him to chill on using bleeding-edge stuff.

Jerry



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Odd overflow exception being raised in one-line program
  2013-01-31  7:37 ` Jerry
@ 2013-01-31 20:44   ` Simon Wright
  2013-02-01  3:25   ` Jerry
  1 sibling, 0 replies; 6+ messages in thread
From: Simon Wright @ 2013-01-31 20:44 UTC (permalink / raw)


Jerry <lanceboyle@qwest.net> writes:

> Thanks for the comments, guys. Randy: I mentioned that the user with
> the problem is on Fedora Rawhide. Simon: Thanks for checking some
> other compilers.
>
> I'll report back to the user and I guess tell him to chill on using
> bleeding-edge stuff.

Tried with the latest GCC: no exception raised.

Target: x86_64-apple-darwin12
gcc version 4.8.0 20130131 (experimental) [trunk revision 195611] (GCC) 

There was one ACATS fail, c52104y, presumably related to
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50678 (perhaps Apple have
fixed the bug?) 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Odd overflow exception being raised in one-line program
  2013-01-31  7:37 ` Jerry
  2013-01-31 20:44   ` Simon Wright
@ 2013-02-01  3:25   ` Jerry
  1 sibling, 0 replies; 6+ messages in thread
From: Jerry @ 2013-02-01  3:25 UTC (permalink / raw)


On Thursday, January 31, 2013 12:37:25 AM UTC-7, Jerry wrote:
> Thanks for the comments, guys. Randy: I mentioned that the user with the problem is on Fedora Rawhide. Simon: Thanks for checking some other compilers.

> I'll report back to the user and I guess tell him to chill on using bleeding-edge stuff.
> 
> Jerry

The user filed this:
https://bugzilla.redhat.com/show_bug.cgi?id=906516



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-02-01  3:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-30  3:49 Odd overflow exception being raised in one-line program Jerry
2013-01-30 10:15 ` 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

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