From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b3c479d8e293030d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!z3g2000prz.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Unconstrained base subtype questions Date: Thu, 31 Mar 2011 14:10:55 -0700 (PDT) Organization: http://groups.google.com Message-ID: <51943393-9b44-4ccd-8e9f-6e55c68e7813@z3g2000prz.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301605855 22160 127.0.0.1 (31 Mar 2011 21:10:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 31 Mar 2011 21:10:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z3g2000prz.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19606 Date: 2011-03-31T14:10:55-07:00 List-Id: On Mar 31, 1:25=A0pm, "Alex Mentis" wrote: > The following does not cause a constraint error in my version of GNAT > on my system: > > ... > > Integer_Result :=3D (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