Crash when attempting to call mpz_invert in a program that uses mpq_class and mpz_class
Álvaro Begué
alvaro.begue at gmail.com
Fri Mar 24 23:31:48 UTC 2017
I see. I failed to initialize the mpz_t. I have successfully used the C++
style many times before, but there doesn't seem to be a C++ version of
mpz_invert.
Anyway, sorry about the bogus report.
Álvaro.
On Fri, Mar 24, 2017 at 7:26 PM Torbjörn Granlund <tg at gmplib.org> wrote:
> Á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