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=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a6b:9591:: with SMTP id x139-v6mr12734881iod.106.1526950726332; Mon, 21 May 2018 17:58:46 -0700 (PDT) X-Received: by 2002:a9d:51d1:: with SMTP id d17-v6mr57326oth.12.1526950726170; Mon, 21 May 2018 17:58:46 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.swapon.de!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!v8-v6no5201527itc.0!news-out.google.com!f20-v6ni5782itd.0!nntp.google.com!u74-v6no5142987itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 21 May 2018 17:58:45 -0700 (PDT) In-Reply-To: <8d534f74-efa1-42ab-aa8a-2826b4cd6cc9@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=47.185.233.194; posting-account=zwxLlwoAAAChLBU7oraRzNDnqQYkYbpo NNTP-Posting-Host: 47.185.233.194 References: <7ba47ec1-28e7-43e1-83a0-2a4d2cf0fd92@googlegroups.com> <87vabgn7rk.fsf@nightsong.com> <8d534f74-efa1-42ab-aa8a-2826b4cd6cc9@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <15f2a899-7a28-4a2f-9531-b89af67b549b@googlegroups.com> Subject: Re: Should exceeding the range of Integer wrap around a la C? From: "Dan'l Miller" Injection-Date: Tue, 22 May 2018 00:58:46 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: reader02.eternal-september.org comp.lang.ada:52562 Date: 2018-05-21T17:58:45-07:00 List-Id: On Monday, May 21, 2018 at 7:39:54 PM UTC-5, Jere wrote: > On Monday, May 21, 2018 at 3:11:45 PM UTC-4, Paul Rubin wrote: > > > Should exceeding the range of Integer wrap around a la C? > > SNIPPED.. > >=20 > > In C, unsigned integer overflow is undefined behaviour, like a subscrip= t > > overflow. Wraparound is one common result because of how machine > > arithmetic works, but it is not guaranteed. The program could instead > > crash, or delete your files, or anything else. See here: > >=20 > > http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html >=20 > Just wanted to point this out because I think you have a typo, but=20 > overflow for unsigned integers is completely defined in the C standard. > It is considered wraparound logic [1]. Signed integer overflow is=20 > undefined behavior however. >=20 > [1] Section 6.2.5/9 of the C11 standard Yes, it has been there for quite some time, all the way back to ANSI C in 1= 989, IIRC. P.J. Plaugher was the main driver of modulo arithmetic as the s= ound theoretical basis of unsigned integer types' overflow (and underflow b= elow zero). Standard C has a different concept of byte though: sometimes = 8-bit, sometimes 9-bit, sometimes 16-bit, sometimes 32-bit. So =E2=80=A2wh= en=E2=80=A2 an unsigned char overflows to wrap around back to zero via modu= lo arithmetic can vary per target hardware ISA.