mpz_limbs_modify doesn't clear new limbs
marco.bodrato at tutanota.com
marco.bodrato at tutanota.com
Thu Jan 2 12:37:50 CET 2025
Ciao,
2 gen 2025, 12:27 da ivomaffei at gmail.com:
> This is indeed my issue.
>
> If I call xptr = mpz_limbs_modify(x,n), then xptr[0..mpz_size(x)) is the
> value of x,
>
Exact.
> The above "feels wrong", but if it's not considered a bug, then perhaps the
> manual should make this clear for newbies like me.
>
Should we add something like the following to the manual?
diff -r e84c5c785bbe doc/gmp.texi
--- a/doc/gmp.texi Wed Dec 04 18:26:27 2024 +0100
+++ b/doc/gmp.texi Thu Jan 02 12:36:04 2025 +0100
@@ -4261,7 +4261,8 @@
Return a pointer to the limb array, intended for write access. The array is
reallocated as needed, to make room for @var{n} limbs. Requires @math{@var{n}
> 0}. The @code{mpz_limbs_modify} function returns an array that holds the old
-absolute value of @var{x}, while @code{mpz_limbs_write} may destroy the old
+absolute value of @var{x} (in the first @code{mpz_size}(@var{x}) limbs, the
+other ones are undefined), while @code{mpz_limbs_write} may destroy the old
value and return an array with unspecified contents.
@end deftypefun
Ĝis,mb
More information about the gmp-discuss
mailing list