64bit integer literals on 32bit platforms

Gereon Kremer gereon.kremer at cs.rwth-aachen.de
Thu Oct 29 09:23:41 UTC 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

We are using gmp in a library project that is supposed to work on both
32bit and 64bit platforms.
However, we ran into problem when we used integer literals that are
larger than 2^32 (say 10000000000).
Consider the following code:

#include <gmpxx.h>
int main() {
mpz_class x(10000000000);
}

On 64bit platforms, everything will be fine. On 32bit however, gmp only
provides constructors from char, short, int and long int, but not long
long int. Thus, compilers (g++, clang++) will tell you that the
constructor is ambiguous.

Tested on Ubuntu 14.04 (32bit), prepackaged gmp 5.1.3, g++ 4.8.2,
clang++ 3.4

Best regards,
Gereon Kremer

- -- 
Gereon Kremer
Lehr- und Forschungsgebiet Theorie Hybrider Systeme
RWTH Aachen
Tel: +49 241 80 21243
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJWMeWbAAoJEIQ2nMX673HfBs0IAJ8isRlXgWarigfMbDRJ6azV
/SdXe8qNe6BsMa0AZc5UGABi3PVChEF/wWbVn+HxOMPQdYD2Td0c08MHggGnKcsT
sdnX1F4BNzgPXQibLZv9nVgEpujO8LIYLjiHSEfJxUDGMwgGKlOL4+3ANUUACxlj
ycilr6mu5k5e3XusbkmmiarYCir4a85uugRxrKrZhz76tKPWJ0MoOzqJnT3UZ2iU
4YrqSqI9gRado3bF4UxNTabtO2T19SGOdGjUnt7IVGZ5HgCEyZI5iuQWWPl8C3Fw
wpirVWZcmqy/5ZhJdaXqMNa0fK7CmfJZaIbTRzm2nztubuutKtOsyybIQuWKIHg=
=T5GA
-----END PGP SIGNATURE-----




More information about the gmp-bugs mailing list