mpq_cmp_z

Marc Glisse marc.glisse at inria.fr
Fri Aug 21 07:14:55 UTC 2015


On Fri, 21 Aug 2015, Torbjörn Granlund wrote:

> "Marco Bodrato" <bodrato at mail.dm.unipi.it> writes:
>
>  Maybe we can "promise" the right type, by adding an explicit cast?
>  SIZ((mpz_srcptr) NUM(op2))
> 
> Except that we should cast op2, not NUM(ops).
>
> I am not sure Marc's reasoning is accurate, nor am I suggesting it is
> not, I've forgotten this level of detail of the C standard.  I am not
> too enthusiastic about passing the wrong type, but if we add casts both
> when going to &mpq and when going back to &mpz, I cannot see how that
> could break with a conforming compiler.

Good point. I agree that (mpz_srcptr)op2 is a safer way to do the same 
thing as NUM(op2) in this case.

(I am not suggesting changing the gmp-impl implementation of NUM to a 
cast)

-- 
Marc Glisse


More information about the gmp-devel mailing list