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 <[email protected]> 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 [email protected] https://gmplib.org/mailman/listinfo/gmp-bugs
