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 14:10:55 -0700 (PDT)
Date: 2011-03-31T14:10:55-07:00	[thread overview]
Message-ID: <51943393-9b44-4ccd-8e9f-6e55c68e7813@z3g2000prz.googlegroups.com> (raw)
In-Reply-To: in2nv8$v3e$1@dont-email.me

On Mar 31, 1:25 pm, "Alex Mentis" <f...@invalid.invalid> wrote:
> The following does not cause a constraint error in my version of GNAT
> on my system:
>
> ...
>
> Integer_Result := (Integer'Last + Integer'Last) / 2;
>
> ...
>
> If I understand correctly, this is because the Integer operators are
> defined for operands of type Integer'Base, which is an unconstrained
> subtype and allows the operands to be stored in extended-length
> registers so that intermediate values in calculations do not overflow.

No, it's because all the operands are known at compile time and the
compiler can just figure out what the answer is.  There is no question
about "where operands are stored" or about how registers are used.
The code for this statement should not perform any addition or
division (or shift) operations.  See 4.9.

                            -- Adam



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