Crash when attempting to call mpz_invert in a program that uses mpq_class and mpz_class
Torbjörn Granlund
tg at gmplib.org
Fri Mar 24 23:26:09 UTC 2017
Álvaro Begué <alvaro.begue at gmail.com> writes:
mpz_class fraction_mod_m(mpq_class x, mpz_class m) {
mpz_t inverse;
mpz_class den = x.get_den();
mpz_invert(inverse, den.get_mpz_t(), m.get_mpz_t()); // Crashes
return mpz_class(inverse);
}
No GMP bug.
Please re-read
https://gmplib.org/manual/GMP-Basics.html, in particular
https://gmplib.org/manual/Variable-Conventions.html in order to use GMP
in C-style correctly.
Why do you mix C++ style and C style?
--
Torbjörn
Please encrypt, key id 0xC8601622
More information about the gmp-bugs
mailing list