Skip to content

Fixed a compilation error (cargo install reform) in deserialize_integer - #2

Open
tueda wants to merge 1 commit into
benruijl:masterfrom
tueda:fix-serialize
Open

Fixed a compilation error (cargo install reform) in deserialize_integer#2
tueda wants to merge 1 commit into
benruijl:masterfrom
tueda:fix-serialize

Conversation

@tueda

@tueda tueda commented Dec 26, 2020

Copy link
Copy Markdown
Collaborator

This patch fixes cargo install reform failure due to a change in gmp-mpfr-sys 1.3.0 (namely, gmp::mpz_t). The patch uses std::mem::MaybeUninit::uninit and gmp_mpfr_sys::gmp::mpz_init..

Other possible workarounds are, if you like to take,

  1. to fix the version of gmp-mpfr-sys as ~1.1.4 in Cargo.toml,

or

  1. to use zero-fill initialization of mpz_t as
let mut res = MaybeUninit::zeroed().assume_init();

which should work as the old code, though it is uncertain in GMP/gmp_mpfr_sys documents and may change in future.

"cargo install reform" failed because

- Cargo.toml specifies gmp-mpfr-sys 1.1.4 (which means ^1.1.4),
- "cargo install" doesn't care Cargo.lock, so the latest version of
  gmp-mpfr-sys (currently 1.4.2) is used,
- Since gmp_mpfr_sys 1.3.0, the internal structure of mpz_t has been
  changed slightly, using std::ptr::NonNull (introduced in Rust 1.25)
  instead of raw pointers, which breaks the code in deserialize_integer.

To fix the issue, this patch adopts the safest way to do the same thing
as the old code:

- use std::mem::MaybeUninit::uninit (introduced in Rust 1.36),
- call gmp_mpfr_sys::gmp::mpz_init.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant