On 3/19/22 04:44, Niels Möller wrote:
Paul Eggert <egg...@cs.ucla.edu> writes:

In libgmp 6.2.1, mini-gmp.c defines a macro without using it, causing
the command "gcc -Wunused-macros -Werror" to fail with the following
diagnostic:

I haven't used -Wunused-macros before, I take it it warns only about
macros defined in .c files? Since it's perfectly normal that macros
defined in .h files are unused in some of the compilation units
including the .h file?

Yes, that's right.


mini-gmp.c is a bit special, in that one more-or-less recommended
usecase is to #include this file into some other compilation unit. E.g.,
like in https://gmplib.org/repo/gmp/file/tip/bootstrap.c#l33.

But probably still shouln't define macros not used within mini-gmp.c;
any additional utility macros should probably go in mini-gmp.h, and be
compatible with public macros from gmp.h.

MPN_PTR_SWAP is an internal macro, though, and I expect you don't want it to be public.

A couple of days ago Marco gave a simple fix that looks like a win, as it also makes mini-gmp.c shorter and easier to read; please see attachment. Could you please install that? Thanks.
--- Begin Message ---
Ciao Paul,

Il 2022-03-09 02:56 Paul Eggert ha scritto:
In libgmp 6.2.1, mini-gmp.c defines a macro without using it, causing

Thanks for spotting this!

Proposed patch attached.

There is also a different possible way to heal the problem: using it :-D

diff -r a44f487c8d20 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c       Fri Mar 11 21:13:20 2022 +0100
+++ b/mini-gmp/mini-gmp.c       Thu Mar 17 19:15:51 2022 +0100
@@ -1938,8 +1938,7 @@
 mpz_swap (mpz_t u, mpz_t v)
 {
   MP_SIZE_T_SWAP (u->_mp_size, v->_mp_size);
-  MP_SIZE_T_SWAP (u->_mp_alloc, v->_mp_alloc);
-  MP_PTR_SWAP (u->_mp_d, v->_mp_d);
+  MPN_PTR_SWAP (u->_mp_d, u->_mp_alloc, v->_mp_d, v->_mp_alloc);
 }



Ĝis,
m

--- End Message ---
_______________________________________________
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs

Reply via email to