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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:455e:: with SMTP id y91-v6mr8962356ita.0.1526918265152; Mon, 21 May 2018 08:57:45 -0700 (PDT) X-Received: by 2002:a9d:5c8d:: with SMTP id a13-v6mr1436955oti.0.1526918264995; Mon, 21 May 2018 08:57:44 -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!u74-v6no4690076itb.0!news-out.google.com!f20-v6ni5402itd.0!nntp.google.com!v8-v6no4741250itc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 21 May 2018 08:57:44 -0700 (PDT) In-Reply-To: <7ba47ec1-28e7-43e1-83a0-2a4d2cf0fd92@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a02:c7d:3c35:b000:325a:3aff:fe0f:37a5; posting-account=L2-UcQkAAAAfd_BqbeNHs3XeM0jTXloS NNTP-Posting-Host: 2a02:c7d:3c35:b000:325a:3aff:fe0f:37a5 References: <7ba47ec1-28e7-43e1-83a0-2a4d2cf0fd92@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Should exceeding the range of Integer wrap around a la C? From: Lucretia Injection-Date: Mon, 21 May 2018 15:57:45 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:52546 Date: 2018-05-21T08:57:44-07:00 List-Id: On Monday, 21 May 2018 16:23:21 UTC+1, 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) > 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? Your compiler is ancient, upgrade to to at least 6.4.0. On my machine with 6.4.0, gnatmake compute, then I run it, I get this: $ ./compute 1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288 1048576 2097152 4194304 8388608 16777216 33554432 67108864 134217728 268435456 536870912 1073741824 raised CONSTRAINT_ERROR : compute.adb:8 overflow check failed I didn't even specify "-gnata -gnato -gnatE" to gnatmake as I normally would, you want those options BTW.