comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent Guerby <guerby@acm.org>
Subject: Re: C++ to Ada95 -- bitten!
Date: 10 Sep 2000 09:39:30 +0200
Date: 2000-09-10T07:38:26+00:00	[thread overview]
Message-ID: <867l8kelvx.fsf@acm.org> (raw)
In-Reply-To: xoEu5.688$zo.18789@news1.mts.net

"Nick J Chackowsky" <nick@arcticmail.com> writes:
> Ahaaaa... the _compiler_ attempted to "solve" the poorly formed exponent and
> crashed in the attempt?

That's likely to be the explanation. Note that the compiler is
required by the standard to be exact for static numerical computations.

The following code should print 1.0 on all Ada 95 compilers
(and the constant will be generated at compile time, look at
the assembly generated using the -S GCC switch).

with Ada.Text_IO; use Ada.Text_IO;

procedure PT is
   X : constant := 1.0 + 2.0 ** (-1000);
   Y : constant := 1.0 + 2.0 ** (-1001);
   Z : constant := 2.0 ** (1001) * (X - Y);
begin
   Put_Line (Float'Image (Z));
end PT;


> I too would have expected a compile error rather than a compiler crash. I
> will submit a bug report.

Reasonable. Note that you should mention what compiler you are using
together with its version and the OS (wether you're submitting a bug
or posting here for help ;-).

-- 
Laurent Guerby <guerby@acm.org>



  reply	other threads:[~2000-09-10  7:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-10  1:24 C++ to Ada95 -- bitten! Nick J Chackowsky
2000-09-10  2:28 ` Al Christians
2000-09-10  3:07 ` (null)
2000-09-10  4:49   ` Nick J Chackowsky
2000-09-10  7:39     ` Laurent Guerby [this message]
2000-09-10 15:47       ` Robert Dewar
replies disabled

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