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 10.224.205.138 with SMTP id fq10mr472259qab.1.1369325366024; Thu, 23 May 2013 09:09:26 -0700 (PDT) X-Received: by 10.49.107.234 with SMTP id hf10mr1342391qeb.21.1369325365993; Thu, 23 May 2013 09:09:25 -0700 (PDT) Path: border1.nntp.ams.giganews.com!nntp.giganews.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!news.glorb.com!ch1no818174qab.0!news-out.google.com!y6ni51104qax.0!nntp.google.com!t14no454494qam.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 23 May 2013 09:09:25 -0700 (PDT) In-Reply-To: <9d131b52-1fe8-4fcb-bb99-c034cefadeee@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=81.208.111.82; posting-account=oHzcLgoAAABFpNphGe9IcFOcH3Xdo-As NNTP-Posting-Host: 81.208.111.82 References: <7cd707ce-ebc5-4df1-9ec3-4f99ce87a07d@googlegroups.com> <96af9cd4-3368-4866-a38e-2514a0a7a54d@googlegroups.com> <9d131b52-1fe8-4fcb-bb99-c034cefadeee@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <17520a7b-5d05-43d1-bee6-90127a1365f0@googlegroups.com> Subject: Re: Simple loop with a strange output From: Luca Cappelletti Injection-Date: Thu, 23 May 2013 16:09:26 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:181733 Date: 2013-05-23T09:09:25-07:00 List-Id: Il giorno gioved=EC 23 maggio 2013 16:41:24 UTC+2, Adam Beneschan ha scritt= o: > On Thursday, May 23, 2013 7:37:24 AM UTC-7, Adam Beneschan wrote: >=20 > > On Thursday, May 23, 2013 6:53:19 AM UTC-7, Luca Cappelletti wrote: >=20 > =20 >=20 > > > do you know what's happening? >=20 > =20 >=20 > > Overflow. >=20 > >=20 >=20 > > The largest possible value of an "integer" type on this platform is (2*= *31)-1. So when X hits 2**30 and then you double it, the actual value, 2**= 31, won't fit in an integer. If you use the right flags when compiling (I = don't remember what they are),=20 >=20 >=20 >=20 > OK, if you compile with -gnato, it will do the check, and now the program= will die on a Constraint_Error instead of getting into an infinite loop. >=20 Yes this is the new output: $ gnatmake -gnato hello.adb=20 gcc-4.4 -c -gnato hello.adb gnatbind -x hello.ali gnatlink hello.ali $ ./hello Start counting 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 : hello.adb:9 overflow check failed do you know why the overflow checking is off by default? I mean I expect gnat force me to understand my errors via it's own debug me= ssages instead works closed how gcc do for C leaving developer into the dar= k thank you very much Luca