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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:a6b:d405:: with SMTP id l5-v6mr12267066iog.70.1526928452921; Mon, 21 May 2018 11:47:32 -0700 (PDT) X-Received: by 2002:a9d:6183:: with SMTP id g3-v6mr3376otk.3.1526928452670; Mon, 21 May 2018 11:47:32 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.uzoreto.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!v8-v6no4890451itc.0!news-out.google.com!b185-v6ni4351itb.0!nntp.google.com!u74-v6no4836258itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 21 May 2018 11:47:32 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=149.32.224.43; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 149.32.224.43 References: <7ba47ec1-28e7-43e1-83a0-2a4d2cf0fd92@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7a56c265-a2fb-4a75-b4e8-8abfd16ba432@googlegroups.com> Subject: Re: Should exceeding the range of Integer wrap around a la C? From: Anh Vo Injection-Date: Mon, 21 May 2018 18:47:32 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:52551 Date: 2018-05-21T11:47:32-07:00 List-Id: On Monday, May 21, 2018 at 9:46:30 AM UTC-7, Simon Wright wrote: > Anh Vo writes: > > > On Monday, May 21, 2018 at 8:23:21 AM UTC-7, nrs...@gmail.com wrote: > > >> I expect this program to print powers of 2 until `X` exceeds the > >> range of Integer. Instead, it seems to "wrap around" with the > >> following (abbreviated) output: > >> 1 > >> 2 > >> 4 > >> [...] > >> 268435456 > >> 536870912 > >> 1073741824 > >> -2147483648 > >> 0 > >> 0 > >> [...] > >> 0 > >> > >> I am compiling with GNAT 4.9.2 on a Debian Linux system using `gnat > >> make compute` with no further compiler flags. Are my expectations > >> wrong, or is this incorrect behavior? > > > > A Constraint_Error must be raised. If not, it is a compiler bug. > > This isn't a bug, it's a feature of older GNATs; AdaCore thought that > checking for overflow of machine integers would be too inefficient. The > fact that (a) everyone puts -gnato in their options and (b) -gnato is > now the default indicate that that thought was wrong (or, at any rate, > became wrong a good while ago). I rechecked the ARM 11.5 (16 and 27/2) again. You are correct. The implementer is allowed to suppress Overflow_Check instead of language required overflow check.