undefined behavior in GMP 5.1.2

Marc Glisse marc.glisse at inria.fr
Sat Sep 21 11:57:42 CEST 2013


On Sat, 21 Sep 2013, Marc Glisse wrote:

> I think an, bn, rn can't be large in this test so we can just cast them to 
> int.

Done.

> s/1L/1UL/ that one is easy :-)

Done.

>> get_str.c:538:52: runtime error: index -1 out of bounds for type 'powers_t 
>> [64]'

It doesn't like array-1+offset, so I changed it to array+(offset-1) so 
that no temporary points outside the array.

>> mul.c:81:31: runtime error: signed integer overflow: -5260204364771764878 + 
>> -5260204364771764878 cannot be represented in type 'long'

We don't check for underflow in mpf multiplication, I didn't touch that. 
People should use mpfr ;-)

-- 
Marc Glisse


More information about the gmp-bugs mailing list