Report: gmp-6.1.2 on MacOS 10.15 using GCC and two Clang
haberg-1 at telia.com
Sun Oct 20 12:59:55 UTC 2019
> On 20 Oct 2019, at 13:24, Torbjörn Granlund <tg at gmplib.org> wrote:
> Hans Åberg <haberg-1 at telia.com> writes:
> I have compiled gmp-6.1.2 on MacOS 10.15 using the inhouse Apple clang
> and the MacPorts gcc9 and clang9, with ‘make check’. All tests passed
> on gcc9, but the two clang had one error each.
> Several people seem to have trouble with using clang. When clang first
> appeared, I isolated several of the GMP failures only to determine that
> they were clang codegen bugs. I don't have time to debug clang for
> Apple or the other clang devs, and this new GMP failure is with very
> high probability yet another clang codegen bug.
Then I will have to do it for you: :-)
It is an optimization issue. When turning it off, both clang pass.
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 do not know if anything like that is done in GMP.
More information about the gmp-bugs