comp.lang.ada
 help / color / mirror / Atom feed
From: Jere <jhb.chat@gmail.com>
Subject: Re: Should exceeding the range of Integer wrap around a la C?
Date: Mon, 21 May 2018 17:39:52 -0700 (PDT)
Date: 2018-05-21T17:39:52-07:00	[thread overview]
Message-ID: <8d534f74-efa1-42ab-aa8a-2826b4cd6cc9@googlegroups.com> (raw)
In-Reply-To: <87vabgn7rk.fsf@nightsong.com>

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..
> 
> In C, unsigned integer overflow is undefined behaviour, like a subscript
> 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:
> 
> http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html

Just wanted to point this out because I think you have a typo, but 
overflow for unsigned integers is completely defined in the C standard.
It is considered wraparound logic [1].  Signed integer overflow is 
undefined behavior however.

[1] Section 6.2.5/9 of the C11 standard


  reply	other threads:[~2018-05-22  0:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-21 15:23 Should exceeding the range of Integer wrap around a la C? nrs5134
2018-05-21 15:27 ` Jacob Sparre Andersen
2018-05-21 15:45 ` Anh Vo
2018-05-21 16:46   ` Simon Wright
2018-05-21 18:47     ` Anh Vo
2018-05-21 15:57 ` Lucretia
2018-05-21 16:49   ` Simon Wright
2018-05-21 19:11 ` Paul Rubin
2018-05-22  0:39   ` Jere [this message]
2018-05-22  0:58     ` Dan'l Miller
2018-05-22  1:36     ` Paul Rubin
2018-05-21 20:43 ` nrs5134
2018-05-22 17:52   ` Björn Lundin
2018-05-22 20:11     ` nrs5134
2018-05-22 20:23       ` Björn Lundin
2018-05-23  7:35       ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox