comp.lang.ada
 help / color / mirror / Atom feed
* Problems with gcc, gnat and RedHat 8
@ 2002-10-11  9:14 Reinert Korsnes
  2002-10-11 12:14 ` arvids lemchens
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Reinert Korsnes @ 2002-10-11  9:14 UTC (permalink / raw)


Hi,

I just installed RedHat 8 on my computer and
try to use Ada from the RedHat package.
Seems like I have some problems.

Could someone with similar configuration try this program below ?

----------------------------------------------------------
with Ada.Numerics.Generic_Elementary_Functions,Text_IO;
use Text_IO;
procedure test1 is
   type Real is new Float;
   package Flt_Io is new Text_IO.Float_Io   (Real);
   package Int_Io is new Text_IO.Integer_Io (Integer);
   package E_F is new Ada.Numerics.Generic_Elementary_Functions (Real);

   use E_F,Flt_Io,Int_Io;

   N : Integer := 10;
   x : Real := 10.0;
   begin
     for I in 1 .. N loop
         Put(" x: ");      Put (x,4,7,0);
         Put(" sin(x): "); Put (sin(x),4,7,0);
         New_Line (1);
     end loop;
end;
-----------------------------------------------------------------

** I use the following commands (via Makefile):

gnatmake test1.adb
gcc -c test1.adb
gnatbind -x test1.ali
gnatlink test1.ali

** And I get the following output:

host$ ./test1
 x:   10.0000000 sin(x):    0.0000000
 x:   10.0000000 sin(x): 100663214.2500000
 x:   10.0000000 sin(x): 100663214.2500000
 x:   10.0000000 sin(x): 100663214.2500000
 x:   10.0000000 sin(x): 100663214.2500000
 x:   10.0000000 sin(x): 100663214.2500000
 x:   10.0000000 sin(x): 100663214.2500000
 x:   10.0000000 sin(x): 100663214.2500000
 x:   10.0000000 sin(x): 100663214.2500000
 x:   10.0000000 sin(x): 100663214.2500000

** sin(x) > 1 ?
** What I do wrong here ?  Or something wrong in RH8's Ada ?

reinert





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

* Re: Problems with gcc, gnat and RedHat 8
  2002-10-11  9:14 Problems with gcc, gnat and RedHat 8 Reinert Korsnes
@ 2002-10-11 12:14 ` arvids lemchens
  2002-10-11 15:23 ` zhenggen
  2002-10-12 10:57 ` Florian Weimer
  2 siblings, 0 replies; 7+ messages in thread
From: arvids lemchens @ 2002-10-11 12:14 UTC (permalink / raw)


Hi reinert,

reinert.korsnes@chello.no am 11.10.02 um 11:14 in comp.lang.ada:
> I just installed RedHat 8 on my computer and
> Could someone with similar configuration try this program below ?

Yes.

ich@pc3:/transfer/ich2/ada/my$ gnatmake cla_0.adb
gnatgcc -c cla_0.adb
cla_0.adb:3:11: warning: file name does not match unit name, should be  
"test1.adb"
gnatbind -x cla_0.ali
gnatlink cla_0.ali
ich@pc3:/transfer/ich2/ada/my$ ./cla_0
 x:   10.0000000 sin(x):   -0.5440211
 x:   10.0000000 sin(x):   -0.5440211
 x:   10.0000000 sin(x):   -0.5440211
 x:   10.0000000 sin(x):   -0.5440211
 x:   10.0000000 sin(x):   -0.5440211
 x:   10.0000000 sin(x):   -0.5440211
 x:   10.0000000 sin(x):   -0.5440211
 x:   10.0000000 sin(x):   -0.5440211
 x:   10.0000000 sin(x):   -0.5440211
 x:   10.0000000 sin(x):   -0.5440211

> ** What I do wrong here ?

As it semms, nothing.

> Or something wrong in RH8's Ada ?

As i am using Debian, it may be some distributionrelatad problem.

To evaluate that, you schould reinstall your system using Debian,
and test if the problem has gone.

... may be it is (also) a compilerproblem.

I am using:

ich@pc3:/transfer/ich2/ada/my$ dpkg -l|grep  gnat
ii  gnat           3.14p-3        The GNU Ada 95 compiler


MvfG,

Arvids




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

* Re: Problems with gcc, gnat and RedHat 8
  2002-10-11  9:14 Problems with gcc, gnat and RedHat 8 Reinert Korsnes
  2002-10-11 12:14 ` arvids lemchens
@ 2002-10-11 15:23 ` zhenggen
  2002-10-11 16:15   ` Reinert Korsnes
  2002-10-12 10:57 ` Florian Weimer
  2 siblings, 1 reply; 7+ messages in thread
From: zhenggen @ 2002-10-11 15:23 UTC (permalink / raw)


> ** sin(x) > 1 ?
> ** What I do wrong here ?  Or something wrong in RH8's Ada ?
> 
> reinert

I have met the same problem. After a careful examination I found that
it maybe caused by the implementation of a-numaux.adb. In early
version of gnat(say 3.13p), there is no such a file.  Spec file
a-numaux.ads declares and imports all math functions from C
library(libmath.a). In GCC 3.2,however, a-numaux.adb is provided and
the functions like sin and cos are implemented using inlined FPU asm
instruction of x86 CPU! There is a bug report about this problem in
gcc bug report database. One can work around it by importing these
functions from C math library.



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

* Re: Problems with gcc, gnat and RedHat 8
  2002-10-11 15:23 ` zhenggen
@ 2002-10-11 16:15   ` Reinert Korsnes
  2002-10-14  0:24     ` zhenggen
  0 siblings, 1 reply; 7+ messages in thread
From: Reinert Korsnes @ 2002-10-11 16:15 UTC (permalink / raw)


zhenggen wrote:

>> ** sin(x) > 1 ?
>> ** What I do wrong here ?  Or something wrong in RH8's Ada ?
>> 
>> reinert
> 
> I have met the same problem. After a careful examination I found that
> it maybe caused by the implementation of a-numaux.adb. In early
> version of gnat(say 3.13p), there is no such a file.  Spec file
> a-numaux.ads declares and imports all math functions from C
> library(libmath.a). In GCC 3.2,however, a-numaux.adb is provided and
> the functions like sin and cos are implemented using inlined FPU asm
> instruction of x86 CPU! There is a bug report about this problem in
> gcc bug report database. One can work around it by importing these
> functions from C math library.

How ?

reinert




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

* Re: Problems with gcc, gnat and RedHat 8
  2002-10-11  9:14 Problems with gcc, gnat and RedHat 8 Reinert Korsnes
  2002-10-11 12:14 ` arvids lemchens
  2002-10-11 15:23 ` zhenggen
@ 2002-10-12 10:57 ` Florian Weimer
  2002-10-13 10:19   ` Simon Wright
  2 siblings, 1 reply; 7+ messages in thread
From: Florian Weimer @ 2002-10-12 10:57 UTC (permalink / raw)


Reinert Korsnes <reinert.korsnes@chello.no> writes:

> ** What I do wrong here ?  Or something wrong in RH8's Ada ?

It appears that this particular bug will be fixed in GCC 3.3.



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

* Re: Problems with gcc, gnat and RedHat 8
  2002-10-12 10:57 ` Florian Weimer
@ 2002-10-13 10:19   ` Simon Wright
  0 siblings, 0 replies; 7+ messages in thread
From: Simon Wright @ 2002-10-13 10:19 UTC (permalink / raw)


Florian Weimer <fw@deneb.enyo.de> writes:

> Reinert Korsnes <reinert.korsnes@chello.no> writes:
> 
> > ** What I do wrong here ?  Or something wrong in RH8's Ada ?
> 
> It appears that this particular bug will be fixed in GCC 3.3.

The last 3.3 I have is an update done 22 September, and it is OK in
that.

   smaug[11]$ GNAT_PREFIX=/opt/gcc-3.3-20020922 gnatmake -f test1
   gcc -c test1.adb
   gnatbind -x test1.ali
   gnatlink test1.ali
   smaug[12]$ ./test1
    x:   10.0000000 sin(x):   -0.5440211
    x:   10.0000000 sin(x):   -0.5440211
    x:   10.0000000 sin(x):   -0.5440211
    x:   10.0000000 sin(x):   -0.5440211
    x:   10.0000000 sin(x):   -0.5440211
    x:   10.0000000 sin(x):   -0.5440211
    x:   10.0000000 sin(x):   -0.5440211
    x:   10.0000000 sin(x):   -0.5440211
    x:   10.0000000 sin(x):   -0.5440211
    x:   10.0000000 sin(x):   -0.5440211




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

* Re: Problems with gcc, gnat and RedHat 8
  2002-10-11 16:15   ` Reinert Korsnes
@ 2002-10-14  0:24     ` zhenggen
  0 siblings, 0 replies; 7+ messages in thread
From: zhenggen @ 2002-10-14  0:24 UTC (permalink / raw)


> gcc bug report database. One can work around it by importing these
> > functions from C math library.
> 
> How ?
> 
> reinert

A demo program:

with Ada.Text_Io;
use Ada.Text_Io;
with Interfaces.C;
use Interfaces.C;
with Ada.Numerics.Long_Long_Elementary_Functions;
with Ada.Numerics.Elementary_Functions;
procedure Sin_ada is
   --   pragma Linker_Options("-L/usr/lib/");
   package Llfef renames Ada.Numerics.Long_Long_Elementary_Functions;
   package Fef renames Ada.Numerics.Elementary_Functions;

   pragma Linker_Options("-lm");
   function Sinl(X:Long_Double) return Long_Double;
   function Cosl(X:Long_Double) return Long_Double;
   pragma Import(C,Sinl,"sinl");
   pragma Import(C,Cosl,"cosl");
   X,Y:Long_Double:=0.1;
   Xllf,Yllfsin,yllfcos: Long_Long_Float:=0.0;
   Xf,Yfsin,Yfcos:Float:=0.0;
begin
   Y:=Sinl(X);
   Put_Line("sinl("&Long_Double'Image(X)&")="&Long_Double'Image(Y));
   Y:=Cosl(X);
   Put_Line("cosl("&Long_Double'Image(X)&")="&Long_Double'Image(Y));
   Xllf:=0.1;
   Yllfsin:=Llfef.Sin(Xllf);
   Put_Line("yllfsin is NaN? "&Boolean'Image(not (Yllfsin=Yllfsin)));
   Put_Line("sin("&long_long_float'Image(Xllf)&")="&long_long_float'Image(Yllfsin));
   Yllfcos:=Llfef.Cos(Xllf);
   Put_Line("cos("&long_long_float'Image(Xllf)&")="&long_long_float'Image(Yllfcos));
   Put_Line("-------------");
   Xf:=0.1;
   Yfsin:=fef.Sin(Xf);
   Yfcos:=Fef.Cos(Xf);
   Put_Line("-------------");
   Put_Line("yfsin is NaN? "&Boolean'Image(not (Yfsin=Yfsin)));
   Put_Line("sin("&float'Image(Xf)&")="&float'Image(Yfsin));
   Put_Line("cos("&float'Image(Xf)&")="&float'Image(Yfcos));

end;



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

end of thread, other threads:[~2002-10-14  0:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-11  9:14 Problems with gcc, gnat and RedHat 8 Reinert Korsnes
2002-10-11 12:14 ` arvids lemchens
2002-10-11 15:23 ` zhenggen
2002-10-11 16:15   ` Reinert Korsnes
2002-10-14  0:24     ` zhenggen
2002-10-12 10:57 ` Florian Weimer
2002-10-13 10:19   ` Simon Wright

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