Report: gmp-6.1.2 on MacOS 10.15 using GCC and two Clang
haberg-1 at telia.com
Sun Oct 20 19:58:29 UTC 2019
> On 20 Oct 2019, at 21:44, Torbjörn Granlund <tg at gmplib.org> wrote:
> Hans Åberg <haberg-1 at telia.com> writes:
> A common programming error is assuming that signed integer types are
> two’s complement, because even though all current CPUs are that,
> overflows are undefined in C/C++, and an optimizer can take advantage
> of that. One example from : checking overflows with x > x + 1 may
> work as intended with optimization turned off, but when on, the
> optimizer can assume that it is always false since x + 1 is undefined
> when overflowed.
> I believe we assume signed integers are in two's complement.
> We don't do a lot of arithmetic on signed integers, though.
Strictly, it is for signed overflows one cannot assume modulo 2^n, n = number of bits. For the unsigned integer types it is required, though. Here is a list for various languages:
More information about the gmp-bugs