PATCH: Bad signed int to long long conversion
marc.glisse at inria.fr
Thu Dec 1 07:30:20 CET 2011
On Wed, 30 Nov 2011, H.J. Lu wrote:
> According to
> vl = (mp_limb_t) (unsigned long int) (val >= 0 ? val : -val);
> is undefined when val is LONG_MIN. The enclosed patch
> fixes it.
(I don't think 4.3 is developed anymore, but that code hasn't changed)
I assume this code in gmpxx.h is wrong too? Is there any compiler flag
that detects those?
mpz_set_si(z, l / mpz_get_si(w));
/* if w is bigger than a long then the quotient must be zero,
l==LONG_MIN and w==-LONG_MIN in which case the quotient is -1
mpz_set_si (z, (mpz_cmpabs_ui (w, (l >= 0 ? l : -l)) == 0 ? -1 :
More information about the gmp-bugs