comp.lang.ada
 help / color / mirror / Atom feed
From: "Phil Thornley" <phil.thornley@baesystems.com>
Subject: Re: I think - it's a bug...
Date: Mon, 11 Mar 2002 08:19:43 -0000
Date: 2002-03-11T08:19:43+00:00	[thread overview]
Message-ID: <3c8c686e@pull.gecm.com> (raw)
In-Reply-To: 3C8B184D.49214059@yahoo.com

"Anatoly Chernyshev" <rhezusfactor@yahoo.com> wrote in message
news:3C8B184D.49214059@yahoo.com...
> Hello everybody!
>
> Look at this piece of code:
>
> ----------------------------------------------------------------------
---------------------------
>
> WITH ada.text_io,ada.numerics.elementary_functions;
> USE ada.text_io, ada.numerics.elementary_functions;
> PROCEDURE el_stat_fun IS
>    b            : float := 7.5;
>    a:float:=4.0;
>    rr, z : float;
>    r            : float := 4.0;
>    dz           : float := 0.3;
> BEGIN
>    FOR k IN 0..integer(b/dz) LOOP
>       z:=float(k)*dz;
>       put_line (float'image(1.0-(z/b)));
>       rr:=-a*sqrt((1.0-(z/b)**2))+a+r;
>    END LOOP;
> END el_stat_fun;
> ----------------------------------------------------------------------
------------------------------
>
>
>
>
> When compiled using GNAT 3.14 (WinNT sp 6) it raises
> ADA.NUMERICS.ARGUMENT_ERROR in sqrt function when k goes to 25 because
> the argument for sqrt becomes
> negative (like -X.XXXXXE-07 ... And this is a headache No 1).
> However, if one comments out the put_line string - everything works
> fine.
>

You need to look at the generated code. All the variables are local to
the procedure, so if you comment out the Put_Line then the compiler
might be generating no code at all for the procedure.

Alternatively try changing it so that the variable rr is external to the
procedure (and make it volatile as well).

Cheers,

Phil

--
Phil Thornley
Programmes, Engineering
Warton





  parent reply	other threads:[~2002-03-11  8:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-10  8:24 I think - it's a bug Anatoly Chernyshev
2002-03-10 12:58 ` David C. Hoos, Sr.
2002-03-11  5:33   ` Anatoly Chernyshev
2002-03-11 13:43     ` David C. Hoos
2002-03-11 16:13     ` Stephen Leake
2002-03-11  5:39   ` Jeffrey Carter
2002-03-11 14:53   ` Wes Groleau
2002-03-11 15:15     ` David C. Hoos
2002-03-11  5:32 ` Jeffrey Carter
2002-03-11  5:46   ` Anatoly Chernyshev
2002-03-11  8:19 ` Phil Thornley [this message]
2002-03-11 19:48 ` Anatoly Chernyshev
replies disabled

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