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,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "Alex Mentis" Newsgroups: comp.lang.ada Subject: Unconstrained base subtype questions Date: Thu, 31 Mar 2011 20:25:13 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit Injection-Date: Thu, 31 Mar 2011 20:25:13 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="TfaOIE1E70h9psK9x8LxRg"; logging-data="31854"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oxugyDb9oDAH3x7119IEZGpPXH87woWA=" User-Agent: XanaNews/1.19.1.269 Cancel-Lock: sha1:C7TXQFHb7ywu6pLS+Z9Gr8zrugA= Xref: g2news2.google.com comp.lang.ada:19600 Date: 2011-03-31T20:25:13+00:00 List-Id: 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. My questions are: 1) Do I understand correctly what's going on? 2) Does the language make any guarantees about preventing spurious overflow, or am I just getting lucky with my compiler/architecture? If guarantees are made by the language, what are they? Thanks, Alex