> I noticed that several testcases in the GMP-4.3.2 test suite are failing now
> which did not happen with GCC 4.9.0.  I debugged the first one,
> mpz/convert, and found the file mpn/generic/get_str.c was miscompiled.
> 
> mpn/get_str.c.132t.dse2:
>   pretmp_183 = (sizetype) chars_per_limb_80;
>   pretmp_184 = -pretmp_183;
>   _23 = chars_per_limb_80 + 4294967295;
>   _68 = (sizetype) _23;
>   _28 = _68 + pretmp_184;
> 
> mpn/get_str.c.133t.forwprop4:
>   _28 = 4294967295;
> 
> 
> That is wrong, because chars_per_limb is unsigned, and it is not zero.
> So the right result should be -1.  This makes the loop termination in that
> function fail.

Can't we compute the right result in this case?  4294967295 is almost -1.

> The attached patch fixes these regressions, and because the reasoning
> depends on the TYPE_OVERFLOW_UNDEFINED attribute, a strict overflow warning
> has to be emitted here, at least for widening conversions.

Saturating, floating-point and fixed-point types are already excluded here, 
see the beginning of the function. 

-- 
Eric Botcazou

Reply via email to