comp.lang.ada
 help / color / mirror / Atom feed
* Erroneous results with LOG function when using inline option (-gnatN)
@ 2004-08-03 16:20 Fr?d?ric Ormancey
  2004-08-03 18:40 ` Georg Bauhaus
  2004-08-04 12:46 ` Gautier
  0 siblings, 2 replies; 3+ messages in thread
From: Fr?d?ric Ormancey @ 2004-08-03 16:20 UTC (permalink / raw)


Hello,

When compiling a simple program using Log function, instance from
Ada.Numerics.Generic_Elementary_Functions, I had an erroneous result
when using -gnatN option ( INLINE ).

Using ASM & Source debug with GVD to compare the code generation with
and without -gnatN option, it seems that the INLINE suppress too much
usefull code ...

Source code causing problem :
with Ada, Ada.Numerics, Ada.Numerics.Generic_Elementary_Functions;
with Text_Io;  use Text_Io;

procedure Test_Numeric is

    package Math is new Ada.Numerics.Generic_Elementary_Functions
(Long_Float);
    use Math;

    Taille_Table : Integer := 3534;
    Rang     : Integer := Taille_Table;
    Deux     : constant Integer := 2;
    Rnbval   : Long_Float;
    R,P,Q,D  : Integer := 0;
    T        : Integer := 0;
begin
    Rnbval := Long_Float(Taille_Table); 
    Put_Line(Long_Float'IMAGE(Rnbval));
    Put_Line(Long_Float'IMAGE(Log(Rnbval)));
    Put_Line(Long_Float'IMAGE(Log(2.0)));
    Put_Line(Long_Float'IMAGE(Log(Rnbval)/Log(2.0)));
    T      := Integer(Log(Rnbval)/Log(2.0)) -1;
    Put_Line(Integer'IMAGE(T));
end Test_Numeric;

correct result is :
 3.53400000000000E+03
 8.17018565287964E+00
 6.93147180559945E-01
 1.17870863245516E+01
 11

When using -gnatN option I got this erroneous result :
 3.53400000000000E+03
0.E+14
3.53400000053248E+14
5.04315471466814E-4932
 2147483647

The platform is Linux RedHat 7.2, with GNAT 3.15p. 
Same code compiled with Win2000 GNAT 3.15p seems to be good.

Thanks helping me to find if I made a programation error, or if it is
a bug in compiler.



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

* Re: Erroneous results with LOG function when using inline option (-gnatN)
  2004-08-03 16:20 Erroneous results with LOG function when using inline option (-gnatN) Fr?d?ric Ormancey
@ 2004-08-03 18:40 ` Georg Bauhaus
  2004-08-04 12:46 ` Gautier
  1 sibling, 0 replies; 3+ messages in thread
From: Georg Bauhaus @ 2004-08-03 18:40 UTC (permalink / raw)


Fr?d?ric Ormancey <frederic.ormancey@atosorigin.com> wrote:
 
: correct result is :
: 3.53400000000000E+03
: 8.17018565287964E+00
: 6.93147180559945E-01
: 1.17870863245516E+01
: 11

The above result I get when compiling with GCC 3.4.1 on Debian,
with or without -gnatN.


: When using -gnatN option I got this erroneous result :
: 3.53400000000000E+03
: 0.E+14
: 3.53400000053248E+14
: 5.04315471466814E-4932
: 2147483647

GNAT 3.15p (from NYU) and -gnatN:
 3.53400000000000E+03
3.53400000000001E+14
3.53400000000001E+14
3.53400000000002E+14
 2147483647

adding -gnato gives

 3.53400000000000E+03
3.53400000000001E+14
3.53400000000001E+14
3.53400000000002E+14

raised CONSTRAINT_ERROR : test_numeric.adb:22 overflow check failed


HTH
-- Georg



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

* Re: Erroneous results with LOG function when using inline option (-gnatN)
  2004-08-03 16:20 Erroneous results with LOG function when using inline option (-gnatN) Fr?d?ric Ormancey
  2004-08-03 18:40 ` Georg Bauhaus
@ 2004-08-04 12:46 ` Gautier
  1 sibling, 0 replies; 3+ messages in thread
From: Gautier @ 2004-08-04 12:46 UTC (permalink / raw)


Fr�d�ric Ormancey:

> Hello,
> 
> When compiling a simple program using Log function, instance from
> Ada.Numerics.Generic_Elementary_Functions, I had an erroneous result
> when using -gnatN option ( INLINE ).

I had the same problem with GNAT 3.15p for Win32 (tested on Win 9x
and Win 2K/XP), that for the Sqrt function: result 0. I sent a bug report
to report (_at_) gnat_._com and the reply was that this is a compiler
bug, corrected in more recent versions. So I just wouldn't use
-gnatN with GNAT 3.15p. NB: -gnatn is working fine.

HTH
________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, e-mail address on the Web site!



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

end of thread, other threads:[~2004-08-04 12:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-03 16:20 Erroneous results with LOG function when using inline option (-gnatN) Fr?d?ric Ormancey
2004-08-03 18:40 ` Georg Bauhaus
2004-08-04 12:46 ` Gautier

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