mini-gmp "bug" missing mpz_fits_sint_p / mpz_fits_uint_p

Vincent Lefevre vincent at
Mon Apr 20 09:08:46 UTC 2020

On 2020-04-19 12:23:03 +0200, Niels Möller wrote:
> >> BTW, do we have any C implementation where INT_MAX + INT_MIN == 0,
> >> i.e.,
> >> not using two's complement?
> >
> > I'm almost sure the compiler can optimise that out at compile time.
> Agreed. But if we attempt to support non two's complement, it would be
> interesting if there were some obscure but conforming C implementation
> that could be used to test it. Some C interpreter, not targeting any
> particular hardware, would do fine for this purpose.

I think that in general, you should not write code that depends on
whether INT_MAX + INT_MIN == 0 or not (the constant INT_MAX + INT_MIN
might be useful in some rare cases, but I think that testing whether
this constant is 0 or not should be forbidden). This can mean that
code on implementations with INT_MAX + INT_MIN == 0 would be less
optimized, but no-one cares.

Vincent Lefèvre <vincent at> - Web: <>
100% accessible validated (X)HTML - Blog: <>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

More information about the gmp-devel mailing list