Possible bug in mini-gmp (gmp-6.0.0)
Zach Metzinger
zmetzing at pobox.com
Thu May 14 19:23:21 UTC 2015
Hello,
While trying to generate the value (2^N)-1 for N := {8,512} and using
the mini-gmp library, I did the following:
mpz_init(m);
mpz_set_ui(m, 0);
mpz_setbit(m, n-1);
mpz_sub_ui(m, m, 1);
This produced, in the case of N == 0:
0x81
While the following code:
mpz_set_ui(t0, 1);
mpz_mul_2exp(m, t0, n);
mpz_sub_ui(m, m, 1);
produces the correct result:
0xff
I'm cross-compling from "FreeBSD 9.3-RELEASE" to
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.3 20140228 (release) [ARM/embedded-4_8-branch revision 208322]
The ultimate target is an ARM Cortex-M4.
This might just be the way it works, but I thought I'd report it.
Let me know if you need more information or additional testing.
--- Zach
More information about the gmp-bugs
mailing list