comp.lang.ada
 help / color / mirror / Atom feed
* GNAT Ada.Numerics.Aux question
@ 2003-07-29  3:17 Happy Segfault
  2003-07-29  5:06 ` Anders Wirzenius
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Happy Segfault @ 2003-07-29  3:17 UTC (permalink / raw)


Hi all!  

I'm trying out GtkAda 2.2.0 on my Red Hat 9 system using gcc 3.2.2,
and the testgtk OpenGL demo crashes with a constraint error.  I think
I've tracked down the problem to a call to Ada.Numerics.Aux.Sin, which
is a thin binding to the libm sin function.  What could be going wrong
here?  Why isn't Sin (X) getting the expected value in the program
below?  Oddly, Sqrt (X) seems to work fine.

--
-- test_sin.adb
--
with Ada.Text_IO;
with Ada.Numerics.Aux;
 
procedure test_sin is
  X : Ada.Numerics.Aux.Double;
begin
  X := Ada.Numerics.Aux.Double (2.0);
  X := Ada.Numerics.Aux.Sqrt (X);
  Ada.Text_IO.Put_Line (Ada.Numerics.Aux.Double'Image (X));
  -- output is ' 1.41421356237309505E+00' which is expected
  X := Ada.Numerics.Aux.Double (30.0 * 3.14159 / 180.0);
  X := Ada.Numerics.Aux.Sin (X);
  -- use the pragma Import (C, Sin, "sin"); from Ada.Numerics.Aux
  Ada.Text_IO.Put_Line (Ada.Numerics.Aux.Double'Image (X));
  -- output is '0.E+17' but 0.5 is the expected result
  Ada.Text_IO.Put_Line (Float'Image (Float (X)));
  -- raises constraint error
end test_sin;

Thanks!  

John



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

* Re: GNAT Ada.Numerics.Aux question
  2003-07-29  3:17 GNAT Ada.Numerics.Aux question Happy Segfault
@ 2003-07-29  5:06 ` Anders Wirzenius
  2003-07-29  5:17 ` arvids lemchens
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Anders Wirzenius @ 2003-07-29  5:06 UTC (permalink / raw)


"Happy Segfault" <happysegfault@yahoo.com> wrote in message
news:ed66a020.0307281917.333e3587@posting.google.com...
> Hi all!
>
> I'm trying out GtkAda 2.2.0 on my Red Hat 9 system using gcc 3.2.2,
> and the testgtk OpenGL demo crashes with a constraint error.  I
think
> I've tracked down the problem to a call to Ada.Numerics.Aux.Sin,
which
> is a thin binding to the libm sin function.  What could be going
wrong
> here?  Why isn't Sin (X) getting the expected value in the program
> below?  Oddly, Sqrt (X) seems to work fine.
>
> --
> -- test_sin.adb
> --
> with Ada.Text_IO;
> with Ada.Numerics.Aux;
>
> procedure test_sin is
>   X : Ada.Numerics.Aux.Double;
> begin
>   X := Ada.Numerics.Aux.Double (2.0);
>   X := Ada.Numerics.Aux.Sqrt (X);
>   Ada.Text_IO.Put_Line (Ada.Numerics.Aux.Double'Image (X));
>   -- output is ' 1.41421356237309505E+00' which is expected
>   X := Ada.Numerics.Aux.Double (30.0 * 3.14159 / 180.0);
>   X := Ada.Numerics.Aux.Sin (X);
>   -- use the pragma Import (C, Sin, "sin"); from Ada.Numerics.Aux
>   Ada.Text_IO.Put_Line (Ada.Numerics.Aux.Double'Image (X));
>   -- output is '0.E+17' but 0.5 is the expected result
>   Ada.Text_IO.Put_Line (Float'Image (Float (X)));
>   -- raises constraint error
> end test_sin;
>
> Thanks!
>
> John

Works on Windows XP, Gnat 3.15p:

---------- Run the executable ----------
 1.41421356237309505E+00
 4.99999616987255739E-01
 5.00000E-01
Normal Termination
Output completed (0 sec consumed).

Anders




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

* Re: GNAT Ada.Numerics.Aux question
  2003-07-29  3:17 GNAT Ada.Numerics.Aux question Happy Segfault
  2003-07-29  5:06 ` Anders Wirzenius
@ 2003-07-29  5:17 ` arvids lemchens
  2003-07-29  8:34   ` Preben Randhol
  2003-07-29  8:37 ` Preben Randhol
  2003-07-29 20:01 ` Gerald
  3 siblings, 1 reply; 8+ messages in thread
From: arvids lemchens @ 2003-07-29  5:17 UTC (permalink / raw)


Hello John,

happysegfault@yahoo.com am 28.07.03 um 20:17 in comp.lang.ada:
> I'm trying out GtkAda 2.2.0 on my Red Hat 9 system using gcc 3.2.2,

Compilerrelated Problem?

> -- test_sin.adb

ich@pc3:~$ gm test_sin.adb

GNATMAKE 3.14p (20010503) Copyright 1995-2001 Free Software Foundation,
Inc.
  "test_sin.ali" being checked ...
  -> "test_sin.adb" time stamp mismatch
gnatgcc -c -gnatE -gnatf -gnato -gnatwa test_sin.adb
test_sin.adb:2:18: warning: "ada.numerics.aux" is an internal GNAT unit
test_sin.adb:2:18: warning: use of this unit is non-portable and
version-dependent
End of compilation
gnatbind -x test_sin.ali
gnatlink test_sin.ali
ich@pc3:~$ ./test_sin
1.41421356237309505E+00
4.99999616987255739E-01
5.00000E-01
ich@pc3:~$

Wondering if Ada.Numerics.Generic_Elementary_Functions wouldn't be a
better choice than ada.numerics.aux?

And if not, why?

MvfG,

Arvids




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

* Re: GNAT Ada.Numerics.Aux question
  2003-07-29  5:17 ` arvids lemchens
@ 2003-07-29  8:34   ` Preben Randhol
  0 siblings, 0 replies; 8+ messages in thread
From: Preben Randhol @ 2003-07-29  8:34 UTC (permalink / raw)


arvids lemchens wrote:
> Hello John,
> 
> happysegfault@yahoo.com am 28.07.03 um 20:17 in comp.lang.ada:
>> I'm trying out GtkAda 2.2.0 on my Red Hat 9 system using gcc 3.2.2,
> 
> Compilerrelated Problem?

Yes gnat 3.2 has problems with sin and cos (at least it had then I tried
it). Use Gnat 3.15p instead until the gcc 3.x becomes stable.

You'll find it here => http://libre.act-europe.fr/GNAT/
-- 
Ada95 is good for you.
http://www.crystalcode.com/codemage/MainMenu/Coding/Ada/IntroducingAda.php



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

* Re: GNAT Ada.Numerics.Aux question
  2003-07-29  3:17 GNAT Ada.Numerics.Aux question Happy Segfault
  2003-07-29  5:06 ` Anders Wirzenius
  2003-07-29  5:17 ` arvids lemchens
@ 2003-07-29  8:37 ` Preben Randhol
  2003-07-29 12:37   ` Happy Segfault
  2003-07-29 20:01 ` Gerald
  3 siblings, 1 reply; 8+ messages in thread
From: Preben Randhol @ 2003-07-29  8:37 UTC (permalink / raw)


Happy Segfault wrote:
> Why isn't Sin (X) getting the expected value in the program
> below?

Because 3.2 has a bug with regards to sin and cos. Use Gnat 3.15p until
gcc 3.x becomes stable.

You'll find Gnat 3.15p here: http://libre.act-europe.fr/GNAT/

-- 
Ada95 is good for you.
http://www.crystalcode.com/codemage/MainMenu/Coding/Ada/IntroducingAda.php



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

* Re: GNAT Ada.Numerics.Aux question
  2003-07-29  8:37 ` Preben Randhol
@ 2003-07-29 12:37   ` Happy Segfault
  2003-07-29 12:51     ` Preben Randhol
  0 siblings, 1 reply; 8+ messages in thread
From: Happy Segfault @ 2003-07-29 12:37 UTC (permalink / raw)


Preben Randhol <randhol+abuse@pvv.org> wrote in message news:<slrnbiccgs.1pf.randhol+abuse@kiuk0152.chembio.ntnu.no>...
> Happy Segfault wrote:
> > Why isn't Sin (X) getting the expected value in the program
> > below?
> 
> Because 3.2 has a bug with regards to sin and cos. Use Gnat 3.15p until
> gcc 3.x becomes stable.
> 
> You'll find Gnat 3.15p here: http://libre.act-europe.fr/GNAT/

Thanks for your response!  I was able to find a bug in GCC's bugzilla
that looks related (although it's not Ada.Numerics.Aux):

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11391

Bad news is that it's confirmed in 3.3.  

John



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

* Re: GNAT Ada.Numerics.Aux question
  2003-07-29 12:37   ` Happy Segfault
@ 2003-07-29 12:51     ` Preben Randhol
  0 siblings, 0 replies; 8+ messages in thread
From: Preben Randhol @ 2003-07-29 12:51 UTC (permalink / raw)


Happy Segfault wrote:
> Bad news is that it's confirmed in 3.3.  

Use Gnat 3.15p instead. I guess gcc 3.x will be stable around gcc 4.0

-- 
Ada95 is good for you.
http://www.crystalcode.com/codemage/MainMenu/Coding/Ada/IntroducingAda.php



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

* Re: GNAT Ada.Numerics.Aux question
  2003-07-29  3:17 GNAT Ada.Numerics.Aux question Happy Segfault
                   ` (2 preceding siblings ...)
  2003-07-29  8:37 ` Preben Randhol
@ 2003-07-29 20:01 ` Gerald
  3 siblings, 0 replies; 8+ messages in thread
From: Gerald @ 2003-07-29 20:01 UTC (permalink / raw)


happysegfault@yahoo.com (Happy Segfault) wrote in message news:<ed66a020.0307281917.333e3587@posting.google.com>...
> Hi all!  
> 
> I'm trying out GtkAda 2.2.0 on my Red Hat 9 system using gcc 3.2.2,
> and the testgtk OpenGL demo crashes with a constraint error.  I think
> I've tracked down the problem to a call to Ada.Numerics.Aux.Sin, which
> is a thin binding to the libm sin function.  What could be going wrong
> here?  Why isn't Sin (X) getting the expected value in the program
> below?  Oddly, Sqrt (X) seems to work fine.
> 
> --
> -- test_sin.adb
> --
> with Ada.Text_IO;
> with Ada.Numerics.Aux;
>  
> procedure test_sin is
>   X : Ada.Numerics.Aux.Double;
> begin
>   X := Ada.Numerics.Aux.Double (2.0);
>   X := Ada.Numerics.Aux.Sqrt (X);
>   Ada.Text_IO.Put_Line (Ada.Numerics.Aux.Double'Image (X));
>   -- output is ' 1.41421356237309505E+00' which is expected
>   X := Ada.Numerics.Aux.Double (30.0 * 3.14159 / 180.0);
>   X := Ada.Numerics.Aux.Sin (X);
>   -- use the pragma Import (C, Sin, "sin"); from Ada.Numerics.Aux
>   Ada.Text_IO.Put_Line (Ada.Numerics.Aux.Double'Image (X));
>   -- output is '0.E+17' but 0.5 is the expected result
>   Ada.Text_IO.Put_Line (Float'Image (Float (X)));
>   -- raises constraint error
> end test_sin;
> 
> Thanks!  
> 
> John

You may use gcc-gnat from redhat-rawhide.

Here is what I got on a RH 9.0 system with gcc-gnat from
redhat-rawhide:
gnatmake -O2 test_sin.adb
gcc -c -O2 test_sin.adb
test_sin.adb:2:18: warning: "ada.numerics.aux" is an internal GNAT
unit
test_sin.adb:2:18: warning: use of this unit is non-portable and
version-dependent
gnatbind -x test_sin.ali
gnatlink test_sin.ali

./test_sin 
 1.41421356237309505E+00
 4.99999616987255739E-01
 5.00000E-01

gnatmake -v

GNATMAKE 3.3 20030715 (Red Hat Linux 3.3-14) Copyright 1995-2002 Free
Software Foundation, Inc.

..

you have to install a new binutils package from rawhide too.

Best, Gerald



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

end of thread, other threads:[~2003-07-29 20:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-29  3:17 GNAT Ada.Numerics.Aux question Happy Segfault
2003-07-29  5:06 ` Anders Wirzenius
2003-07-29  5:17 ` arvids lemchens
2003-07-29  8:34   ` Preben Randhol
2003-07-29  8:37 ` Preben Randhol
2003-07-29 12:37   ` Happy Segfault
2003-07-29 12:51     ` Preben Randhol
2003-07-29 20:01 ` Gerald

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