comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Integer'Size < 32 ?
Date: 1996/08/09
Date: 1996-08-09T00:00:00+00:00	[thread overview]
Message-ID: <DvvHrt.HxD@world.std.com> (raw)
In-Reply-To: 9608081258.AA02749@most


In article <9608081258.AA02749@most>,
W. Wesley Groleau (Wes) <wwgrol@PSESERV3.FW.HAC.COM> wrote:
>   .... range -(2**31) .. ((2**31)-1)
>
>I once used a compiler for which Integer'Size = 32 and which had an
>interesting "feature."  It recognized that the above would fit in 32 bits,
>so it compiled for that size.  Then at run-time, it would (obeying
>the precedence rules) try to compute 2**31 and raise constraint_error.

If you mean "type T is range -(2**31) .. ((2**31)-1);", then this cannot
cause C_E, and never could, and would be a serious compiler bug if it
did.

I think you're thinking of this slightly different case:

    subtype S is Integer range 1..(2**31)-1; -- Assume Integer'Last = (2**31)-1.

In Ada 83, the above *might* raise C_E.  There was one compiler that I
know of that would raise C_E -- all others I ever used would get the
right answer.

This problem has been fixed in Ada 95.  In Ada 95 all static expressions
are evaluated exactly, at compile time, without overflow.  Therefore,
the above cannot raise C_E in Ada 95.

- Bob




  reply	other threads:[~1996-08-09  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-08  0:00 Integer'Size < 32 ? W. Wesley Groleau (Wes)
1996-08-09  0:00 ` Robert A Duff [this message]
1996-08-10  0:00 ` Robert Dewar
1996-08-11  0:00 ` Mark A Biggar
1996-08-12  0:00   ` 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