Constructor taking 64-bit integer missing on (some) Windows C++ compilers

Marc Glisse marc.glisse at
Mon Jun 8 20:32:25 UTC 2020

On Sat, 6 Jun 2020, Mihai Preda wrote:

> At this point the C++ compiler on windows (where long is 32-bit)
> reports errors, see at the end. The problem is that the set of
> constructors does not include one taking a 64-bit integer:

The issue is that:
1) the C++ interface follows the C interface
2) the C interface is still C89 (no long long)
3) Microsoft chose an absurd ABI for win64 (32bit long)

3) is unlikely to change, we could change 1) but I'd rather not. The most 
likely evolution is about 2), at some indeterminate point in the future 
(hopefully not too far).

> The fix could consist in having these constructors take int64_t
> instead of long int, etc. I.e. take explicitly-sized typed instead of
> the "long" which is variable-size.

Well, if the function accepts int64_t, it needs to be taught how to handle 
it, the fix isn't that localized.

On Sat, 6 Jun 2020, Vincent Lefevre wrote:

> There's the same issue with 32-bit architectures, whatever the OS.

Indeed. And many users would also appreciate interoperability with 
int128_t (or whatever name it uses on their platform).

> I would rather suggest to support intmax_t and uintmax_t.

That's one possibility for C (and C++, although it is a bit more painful 
there), but not one that everyone agrees with. I think the majority in 
standard committees believes that those 2 types were a mistake, in 
particular because they are 64 bits on platforms that now have a 128 bit 
type, but cannot change intmax_t as that would break the ABI. Still, it 
isn't a bad choice for a large builtin integer type.

Marc Glisse

More information about the gmp-bugs mailing list