mini-gmp warnings

Vincent Lefevre vincent at vinc17.net
Sun Apr 26 20:04:08 UTC 2020


On 2020-04-26 14:31:21 +0200, Niels Möller wrote:
> I'm updating the copy of mini-gmp I use in nettle to the latest version.
> In Nettle, it's compiled with gcc -Wall, and I some new warnings, like
> 
> /home/nisse/hack/nettle/mini-gmp.c: In function ‘mpn_common_scan’:
> /home/nisse/hack/nettle/mini-gmp.c:99:23: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
>      if (GMP_LIMB_BITS > LOCAL_SHIFT_BITS)    \
>                        ^

I've found that -Wsign-compare is useless in practice, until

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470

is fixed. Adding casts or changing types to unsigned could in some
cases add or hide real bugs.

FYI, this bug and bug 4210 are referenced in MPFR's mpfr.h, where it
is important not to trigger warnings as they would hit 3rd-party code.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


More information about the gmp-devel mailing list