comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Unconstrained base subtype questions
Date: Thu, 31 Mar 2011 15:18:18 -0700 (PDT)
Date: 2011-03-31T15:18:18-07:00	[thread overview]
Message-ID: <b6be3d06-cd67-4497-99c3-ae6de6dc4ff7@t19g2000prd.googlegroups.com> (raw)
In-Reply-To: 87wrjfkm57.fsf@ludovic-brenta.org

On Mar 31, 2:36 pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:

> > Well, that's my question. In the calculation above, I clearly have an
> > intermediate value that exceeds Integer'Last. And I tried something
> > similar with Long_Long_Integer and still couldn't get an overflow
> > error! So what is the actual limit on the base range of the type? Is it
> > language defined, compiler defined, hardware defined, none of the above?
>
> It is both language- and implementation-defined.  I gave you the
> references to what the language says.  The implementation-defined part
> is the "base range of the type"; a sane implementation would choose a
> range that matches the hardware.

However, the language does specify that whatever base range the
implementation chooses, Integer'Last will be the top of the range.
It's not legally possible for the "base range" of Integer to include
values that are larger than Integer'Last.  (Note that that applies
only to Standard.Integer; it "should"
apply to other predefined signed integer types in Standard, but it
doesn't apply to user-defined integer types.)

The language does say, though (3.5.4(24)), that implementations don't
need to raise Constraint_Error for arithmetic operations on signed
integers as long as they produce correct results, even if intermediate
results are outside the base range---that's what Randy was referring
to, I think.

                             -- Adam



  reply	other threads:[~2011-03-31 22:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-31 20:25 Unconstrained base subtype questions Alex Mentis
2011-03-31 21:09 ` Ludovic Brenta
2011-03-31 21:26   ` Alex Mentis
2011-03-31 21:36     ` Ludovic Brenta
2011-03-31 22:18       ` Adam Beneschan [this message]
2011-03-31 21:10 ` Adam Beneschan
2011-03-31 21:18 ` Simon Wright
2011-03-31 21:24 ` Randy Brukardt
2011-03-31 21:51   ` Alex Mentis
2011-04-01  8:20     ` Dmitry A. Kazakov
replies disabled

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