Re: unused macro MPN_PTR_SWAP in mini-gmp.c
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 ___ gmp-bugs mailing list gmp-bugs@gmplib.org https://gmplib.org/mailman/listinfo/gmp-bugs
unused macro MPN_PTR_SWAP in mini-gmp.c
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: lib/mini-gmp.c:251: warning: macro "MPN_PTR_SWAP" is not used [-Wunused-macros] 251 | #define MPN_PTR_SWAP(xp,xs, yp,ys) \ | Proposed patch attached.--- mini-gmp/mini-gmp.c-bak 2020-11-14 10:45:09.0 -0800 +++ mini-gmp/mini-gmp.c 2022-03-08 17:50:48.637569187 -0800 @@ -247,11 +247,6 @@ see https://www.gnu.org/licenses/. */ (y) = __mp_srcptr_swap__tmp; \ } while (0) -#define MPN_PTR_SWAP(xp,xs, yp,ys) \ - do { \ -MP_PTR_SWAP (xp, yp); \ -MP_SIZE_T_SWAP (xs, ys); \ - } while(0) #define MPN_SRCPTR_SWAP(xp,xs, yp,ys) \ do { \ MP_SRCPTR_SWAP (xp, yp); \ ___ gmp-bugs mailing list gmp-bugs@gmplib.org https://gmplib.org/mailman/listinfo/gmp-bugs
Re: 2 minor issues on Windows
Might you consider (I verified it works): #if defined (_MSC_VER) #pragma warning(push) #pragma warning(disable: 4146) // unary minus operator applied to unsigned type, result still unsigned #endif *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK; #if defined (_MSC_VER) #pragma warning(pop) #endif Your code, your call. I understand the above does not enhance readability. The other alternative is to apply the pragma to the entire gmp.h file. Regards, George Woltman On Sun, Mar 13, 2022 at 5:24 AM Marco Bodrato wrote: > Ciao, > > Il 2022-03-13 00:06 Torbjörn Granlund ha scritto: > > There is some sort of sick competition between certain compilers to > > have > > the most warnings for valid C. I don't think we should play their > > game, > > > Incidantally, arithmetic on unsigned types is well-defined. Unlike > > that > > of signed types. > > > int > > foo (int a, int b) > > { > > return a + b - 1; > > } > > > > $ clank foo.c > > warning: signed addition might overflow and yield undefined results > > warning: signed subtraction might overflow and yield undefined results > > :-D > You are right! > > Ĝis, > m > ___ gmp-bugs mailing list gmp-bugs@gmplib.org https://gmplib.org/mailman/listinfo/gmp-bugs