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:88cb:: with SMTP id s72-v6mr11755905ioi.117.1526916200991; Mon, 21 May 2018 08:23:20 -0700 (PDT) X-Received: by 2002:a9d:6183:: with SMTP id g3-v6mr63015otk.3.1526916200765; Mon, 21 May 2018 08:23:20 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.linkpendium.com!news.linkpendium.com!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!v8-v6no4709167itc.0!news-out.google.com!b185-v6ni4242itb.0!nntp.google.com!u74-v6no4659771itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 21 May 2018 08:23:20 -0700 (PDT) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2620:0:e50:1004:f426:86ea:db2d:ebc0; posting-account=rzxg2woAAADYt9Sd2iM3FqP7X-QbdITH NNTP-Posting-Host: 2620:0:e50:1004:f426:86ea:db2d:ebc0 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <7ba47ec1-28e7-43e1-83a0-2a4d2cf0fd92@googlegroups.com> Subject: Should exceeding the range of Integer wrap around a la C? From: nrs5134@gmail.com Injection-Date: Mon, 21 May 2018 15:23:20 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:52543 Date: 2018-05-21T08:23:20-07:00 List-Id: Hi all, I'm brand-new to Ada coming from a Fortran & Python background - just starting to write some trivial tutorial programs. I'm trying to understand the output of following program (copied from the "Lovelace" Ada95 tutorial): -- compute.adb -- Demonstrate a trivial procedure, with another nested inside. with Ada.Text_IO, Ada.Integer_Text_IO; use Ada.Text_IO, Ada.Integer_Text_IO; procedure Compute is procedure Double(Item : in out Integer) is begin -- procedure Double Item := Item * 2; end Double; X : Integer := 1; -- Local variable X of type Integer begin -- procedure Compute loop Put(X); New_Line; Double(X); end loop; end Compute; 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? Cheers, NS