Ciao,

Il 2022-02-03 08:50 ni...@lysator.liu.se ha scritto:
George Woltman <wolt...@alum.mit.edu> writes:

Minor issue #2 (I should have reported this years ago, sorry):

In gmp.h, these lines:

mpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n)
[...]
  *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK;

The last line generates this compiler warning:
warning C4146: unary minus operator applied to unsigned type, result still

I can only suggest that you disable or ignore that warning. Operations
on unsigned types is well defined by the C standard, and gmp depends on
practically all possible corner cases to work according to spec.

Maybe we can avoid this in the file gmp.h; it is used during the compiling process of any project using the library...

What about the following?

--- a/gmp-h.in  Fri Mar 11 21:13:20 2022 +0100
+++ b/gmp-h.in  Sat Mar 12 23:23:09 2022 +0100
@@ -2234,7 +2234,7 @@
       ++__gmp_up; ++__gmp_rp;
     }

-  *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK;
+  *__gmp_rp = (1 + ~ *__gmp_up) & GMP_NUMB_MASK;

   if (--__gmp_n) /* Higher limbs get complemented. */
     mpn_com (++__gmp_rp, ++__gmp_up, __gmp_n);


For an optimising compiler, there should not be any difference.

"+ ~ *" is a funny sequence of operators :-)

Ĝis,
m
_______________________________________________
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs

Reply via email to