mpz_set_si loses long long value on Windows

Torbjörn Granlund tg at gmplib.org
Wed Jul 24 09:11:46 UTC 2019


Dim XY <dim0071 at gmail.com> writes:

  a=-2014444032  //  <----- incorrect, lost value!!

  Possible explanation:

  mpz_set_si function has the signature:

  void mpz_set_si (mpz_ptr dest, signed long int val);

Indeed. And you pass an int64_t which may or may not be "signed long
int".  That's a bug in your program, which I suppose you already
understand.

  This 'signed long int' type has different sizes of linux (8 bytes) and
  windows 64bit (4 bytes) platforms
  (https://en.cppreference.com/w/cpp/language/types)

  Maybe it is better to use 'long long' type which always has the size
  of 8 bytes on any platform?

You're essentially lobbying for an incompatible change in GMP by
making a spurious GMP bug report.

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-bugs mailing list