From 8c6a5d7c42665e5ce8043bd489d657a65fa3f1e5 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Wed, 3 Jan 2024 10:19:25 +0100 Subject: [PATCH] Reword comment about delicate points of unmarshaling --- caml_z.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/caml_z.c b/caml_z.c index c0b11c4..85563eb 100644 --- a/caml_z.c +++ b/caml_z.c @@ -3395,14 +3395,17 @@ static void ml_z_custom_serialize(value v, #endif } -/* XXX: serializing a large (i.e., > 2^31) int on a 64-bit machine and - deserializing on a 32-bit machine will fail (instead of returning a - block). - YYY: serializing a large (i.e., > 2^31 and < 2^62) int on a - 32-bit machine and deserializing on a 64-bit machine must fail - (instead of returning a block containing a non-normalized big integer) - (issue #148). - */ +/* There are two issues with integers that are tagged ints on a 64-bit + machine but boxed bigints on a 32-bit machine, namely integers in the + [2^30, 2^62) and [-2^62, -2^30) ranges: + - Serializing such an integer on a 64-bit machine and + deserializing on a 32-bit machine will fail in the generic unmarshaler. + The correct behavior would be to return a boxed integer. + - Serializing such an integer on a 32-bit machine and + deserializing on a 64-bit machine must fail. + The wrong behavior would be to return a block containing a + non-normalized, boxed integer (issue #148). +*/ static uintnat ml_z_custom_deserialize(void * dst) { mp_limb_t* d = ((mp_limb_t*)dst) + 1;