Two possibly relevant warnings in mpn/udiv_w_sdiv.c
marian.kechlibar at circletech.net
Sat Nov 26 16:37:23 CET 2011
Dear GMP developers,
I would like to alert you to a possible problem in the C function
mpn_udiv_w_sdiv (rp, a1, a0, d), which is defined in mpn/udiv_w_sdiv.c.
I have recently tried to compile the file with warnings turned to a high
level, and the compiler alerted me to incorrect assignment. Namely,
the lines q = -1; and q = -2;, very close to the end
of the file, constitute assignment of a negative value to q, which may
be of unsigned type (unsigned long etc.)
I am not even sure whether the code would be portable to a 64-bit
platform, even if q was a signed long, without an explicit marking of
the negative constant as long (something like q = -1L;).
Maybe the code isn't used anymore, and I am alerting you to a
non-problem. But in my personal C/C++ history, I was bitten by such
subtle problems several times, so I want to share the observation with you.
More information about the gmp-devel