The following program computes 1^0 % 1:
//#include <gmp.h>
#include "mini-gmp.c"
#include <stdio.h>
#define CF_CHECK_EQ(expr, res) if ( (expr) != (res) ) { goto end; }
int main(void)
{
mpz_t a, b, c, res;
char* s = NULL;
/* noret */ mpz_init(a);
/* noret */ mpz_init(b);
/* noret */ mpz_init(c);
/* noret */ mpz_init(res);
CF_CHECK_EQ(mpz_set_str(a, "1", 10), 0);
CF_CHECK_EQ(mpz_set_str(b, "0", 10), 0);
CF_CHECK_EQ(mpz_set_str(c, "1", 10), 0);
CF_CHECK_EQ(mpz_set_str(res, "0", 10), 0);
/* noret */ mpz_powm(res, a, b, c);
printf("%s\n", mpz_get_str(NULL, 10, res));
end:
return 0;
}
The result should be 0, which is the case with regular libgmp, but with
mini-gmp the result is 1, and this is incorrect.
Tested on version 6.2.1 and the latest repository checkout, with recent
clang and gcc, on x64 Linux.
_______________________________________________
gmp-bugs mailing list
[email protected]
https://gmplib.org/mailman/listinfo/gmp-bugs