comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Unconstrained base subtype questions
Date: Thu, 31 Mar 2011 23:36:36 +0200
Date: 2011-03-31T23:36:36+02:00	[thread overview]
Message-ID: <87wrjfkm57.fsf@ludovic-brenta.org> (raw)
In-Reply-To: in2rhh$avn$1@dont-email.me

"Alex Mentis" <foo@invalid.invalid> writes:
>> - during execution, there are two kinds of overflow checks.
>>   Intermediate results must lie within the "base range of the type"
>>   which, for all intents and purposes, is the full range of
>>   [[Long_]Long_]Integer (ARM 4.5.4(20)).  So, if an intermediate value
>>   exceeds e.g. Integer'Last you get a Constraint_Error.
>
> 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.

The reason why you did not get an overflow at runtime is because your
computation did not take place at run time.  The GNAT warnings and
Constraint_Error that I reported earlier were for the case of a run-time
computation similar to what Simon and Randy said.

-- 
Ludovic Brenta.



  reply	other threads:[~2011-03-31 21:36 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 [this message]
2011-03-31 22:18       ` Adam Beneschan
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