comp.lang.ada
 help / color / mirror / Atom feed
* Legitimate Argument_Error Or Compiler Bug?
@ 2000-09-25  0:00 Marin David Condic
  2000-09-25  0:00 ` Marin David Condic
  2000-09-30  0:00 ` Robert Dewar
  0 siblings, 2 replies; 3+ messages in thread
From: Marin David Condic @ 2000-09-25  0:00 UTC (permalink / raw)


The following code raises Argument_Error when attempting to compute a
positive fraction to a real power. Now so far as I can tell, there is
nothing particularly undefined about a fraction raised to a real power,
so Argument_Error seems to be out of place here. Either I've got
something wrong or I've tripped across a bug in the compiler (GNAT
3.13p). Is there a reason this exception should be raised or should I
submit a bug report?

Thanks for the help.

MDC


with Ada.Text_Io ;
with Ada.Numerics.Long_Long_Elementary_Functions ;
use Ada.Numerics.Long_Long_Elementary_Functions ;
--
procedure What_The_Heck is

   Alpha        : Long_Long_Float := 0.05;
   Log_Term     : Long_Long_Float;
   Neg_Log_Term : Long_Long_Float;
   Power_Term   : Long_Long_Float;
   --
begin
   --
   Log_Term      := Log(Alpha/2.0 , 10.0) ;
   Neg_Log_Term  := - Log_Term ;
   --
   Ada.Text_Io.Put ("Neg_Log_Term ** 2   is ") ;
   Power_Term    := Neg_Log_Term ** 2 ;
   Ada.Text_Io.Put_Line (Long_Long_Float'Image(Power_Term) ) ;
   --
   Ada.Text_Io.Put ("    Log_Term ** 2   is ") ;
   Power_Term    := Log_Term ** 2 ;
   Ada.Text_Io.Put_Line (Long_Long_Float'Image(Power_Term) ) ;
   --
   Ada.Text_Io.Put ("Neg_Log_Term ** 2.0 is ") ;
   Power_Term     := Neg_Log_Term ** 2.0;
   Ada.Text_Io.Put_Line (Long_Long_Float'Image(Power_Term) ) ;
   --
   Ada.Text_Io.Put ("    Log_Term ** 2.0 is (Argument_Error)") ;
   Power_Term    :=  Log_Term ** 2.0 ;    --  Dies here!
   Ada.Text_Io.Put_Line (Long_Long_Float'Image(Power_Term) ) ;
   --
end What_The_Heck ;

--
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

    "Because that's where they keep the money."

        --  Willie Sutton when asked why he robbed banks.
======================================================================






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

* Re: Legitimate Argument_Error Or Compiler Bug?
  2000-09-25  0:00 Legitimate Argument_Error Or Compiler Bug? Marin David Condic
@ 2000-09-25  0:00 ` Marin David Condic
  2000-09-30  0:00 ` Robert Dewar
  1 sibling, 0 replies; 3+ messages in thread
From: Marin David Condic @ 2000-09-25  0:00 UTC (permalink / raw)


Marin David Condic wrote:

>    Alpha        : Long_Long_Float := 0.05;
>    Log_Term     : Long_Long_Float;
>    Neg_Log_Term : Long_Long_Float;
>    Power_Term   : Long_Long_Float;
>  <snip>
>    --
>    Ada.Text_Io.Put ("    Log_Term ** 2.0 is (Argument_Error)") ;
>    Power_Term    :=  Log_Term ** 2.0 ;    --  Dies here!
>    Ada.Text_Io.Put_Line (Long_Long_Float'Image(Power_Term) ) ;
>

Oooops! Looks like I got the names wrong here. Log_Term is really negative.
Howard Ludwig was kind enough to point out that this case runs into
A.5.1(23) which says that Argument_Error will be raised when the left
operand is negative. Mystery solved and thanks for the input.

MDC
--
======================================================================
Marin David Condic - Quadrus Corporation - http://www.quadruscorp.com/
Send Replies To: m c o n d i c @ q u a d r u s c o r p . c o m
Visit my web site at:  http://www.mcondic.com/

    "Because that's where they keep the money."

        --  Willie Sutton when asked why he robbed banks.
======================================================================






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

* Re: Legitimate Argument_Error Or Compiler Bug?
  2000-09-25  0:00 Legitimate Argument_Error Or Compiler Bug? Marin David Condic
  2000-09-25  0:00 ` Marin David Condic
@ 2000-09-30  0:00 ` Robert Dewar
  1 sibling, 0 replies; 3+ messages in thread
From: Robert Dewar @ 2000-09-30  0:00 UTC (permalink / raw)


In article <39CFA126.6669BF45@acm.org>,
  Marin David Condic <mcondic.nospam@acm.org> wrote:
> The following code raises Argument_Error when attempting to
compute a
> positive fraction to a real power. Now so far as I can tell,
there is
> nothing particularly undefined about a fraction raised to a
real power,
> so Argument_Error seems to be out of place here. Either I've
got
> something wrong or I've tripped across a bug in the compiler
(GNAT
> 3.13p). Is there a reason this exception should be raised or
should I
> submit a bug report?
>
> Thanks for the help.
>
> MDC

I am quite surprised that you did not find the obvious error
here yourself :-) The procedure I would follow to prevent this
kind of temporary blindness (which aflicts us all from time
to time) is to run this in the debugger, break on the exception
and then dump the backtrace, which will immediately show the
negative value and trigger you to look into what is going on!


Sent via Deja.com http://www.deja.com/
Before you buy.




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

end of thread, other threads:[~2000-09-30  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-25  0:00 Legitimate Argument_Error Or Compiler Bug? Marin David Condic
2000-09-25  0:00 ` Marin David Condic
2000-09-30  0:00 ` Robert Dewar

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