C++ Logo

sg14

Advanced search

Re: [SG14] SG14 Sept 8 (Games) zoom call

From: John McFarlane <john_at_[hidden]>
Date: Mon, 25 Oct 2021 10:59:45 +0100
On Sun, 24 Oct 2021 at 03:45, Matt Bentley via SG14 <sg14_at_[hidden]>
wrote:

> * "Opt-in UB on Unsigned Overflow" = more info on this and how it could
> present performance gains would be good.
>

Technically, unsigned overflow is not a thing
<https://eel.is/c++draft/basic.fundamental#2>. I read "Opt-in UB on
Unsigned Overflow" to mean "Opt-in overflow on unsigned integers".

Overflow is an unambiguous bug in C++ which affords signed integers some
opportunities for optimisation that are lacking in unsigned integers. Some
helpful examples can be found in this article
<https://kristerw.blogspot.com/2016/02/how-undefined-signed-overflow-enables.html>
and in the second half of this talk
<https://www.youtube.com/watch?v=yG1OZ69H_-o> by Chandler Carruth.

Note that lack of UB also makes it harder to test for bugs in code that
uses unsigned integers.

HTH,
John

Received on 2021-10-25 04:59:59