bug in t-perfpow for mingw64

Alexander Maly a.a.maly at gmail.com
Tue Sep 14 13:01:29 CEST 2010


>
> Please try the patch from the status section of the GMP webpage:
> http://gmplib.org:8000/gmp-5.0/raw-rev/794410151f5f
>
> --
> Torbjörn

Works for me. Though I did it manually, not by the program 'patch',
since I have already reformatted text of t-perfpow.c when discovered
why it was not working. But there is a subtle moment: in line

gmp_printf("n = %Zu\nprimes[0] = %Zu\nexp[0] = %lu\n", n, primes[0], exp[0]);
it would print exp[0] as unsigned long, and I do not know what is the
format for mp_limb_t in gmp_printf.
So may be it is better to leave exp and e variables as unsigned longs?
They should have very small values,
and their addresses are never else used, so it should not make big difference.
Strange that when I turned warnings on by "-Wall -W" the compiler did
not tell me about wrong arguments size.
However, assigning such attributes to gmp_printf arguments is very
compiler-specific, and may be just impossible if the format string has
non-standart symbols, but it might increase type-safety.
Another offtopic question: when I turned warnings on, the compiler
written the following similar warnings:
In file included from t-perfpow.c:26:0:
../../gmp-impl.h: In function 'mpn_toom32_mul_itch':
../../gmp-impl.h:4568:63: warning: signed and unsigned type in
conditional expression
../../gmp-impl.h: In function 'mpn_toom43_mul_itch':
../../gmp-impl.h:4584:55: warning: signed and unsigned type in
conditional expression
../../gmp-impl.h: In function 'mpn_toom52_mul_itch':
../../gmp-impl.h:4592:63: warning: signed and unsigned type in
conditional expression
../../gmp-impl.h: In function 'mpn_toom62_mul_itch':
../../gmp-impl.h:4606:59: warning: signed and unsigned type in
conditional expression

They are because in that lines the divisors (small constants, like 3)
were casted to (size_t), that is unsigned, while all the other
variables are signed. Is that for a reason, or they may be casted to
(ssize_t) as well (ssize_t is similiar to size_t, but signed) or
leaved as is? I am asking that because the compiler is very helpful in
finding neat errors if warnings are properly turned on and the found
warnings are cleaned in code.


More information about the gmp-bugs mailing list