PATCH: Bad signed int to long long conversion
Marc Glisse
marc.glisse at inria.fr
Thu Dec 1 07:49:47 CET 2011
On Thu, 1 Dec 2011, Marc Glisse wrote:
> On Wed, 30 Nov 2011, H.J. Lu wrote:
>
>> According to
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50066
>>
>> 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?
Actually, all occurences of "-l" in that file need changing :-(
In mpz_get_si, this looks suspicious:
return ~(((long) zl - 1L) & LONG_MAX);
--
Marc Glisse
More information about the gmp-bugs
mailing list