documentation on internals not up to date

Marco Bodrato bodrato at
Fri May 4 21:17:36 UTC 2018


Il Ven, 27 Aprile 2018 10:50 am, Niels Möller ha scritto:
> This is a minor point, but.... The thing is, that when we say that
> _mp_d[0] is readable but "not wanted", that leaves it somewhat unclear

What about the following?

diff -r 85eda8a9f6e2 doc/gmp.texi
--- a/doc/gmp.texi	Fri May 04 21:43:34 2018 +0200
+++ b/doc/gmp.texi	Fri May 04 23:12:34 2018 +0200
@@ -10155,7 +10155,7 @@
 @item @code{_mp_size}
 The number of limbs, or the negative of that when representing a negative
 integer.  Zero is represented by @code{_mp_size} set to zero, in which case
-the @code{_mp_d} data is unused.
+the @code{_mp_d} data is undefined.

 @item @code{_mp_d}
 A pointer to an array of limbs which is the magnitude.  These are stored
@@ -10164,17 +10164,21 @@
 significant.  Whenever @code{_mp_size} is non-zero, the most significant
 is non-zero.

-Currently there's always at least one limb allocated, so for instance
- at code{mpz_set_ui} never needs to reallocate, and @code{mpz_get_ui} can fetch
- at code{_mp_d[0]} unconditionally (though its value is then only wanted if
- at code{_mp_size} is non-zero).
+Currently there's always at least one readable limb, so for instance
+ at code{mpz_get_ui} can fetch @code{_mp_d[0]} unconditionally (though its
+value is undefined if @code{_mp_size} is zero).

 @item @code{_mp_alloc}
 @code{_mp_alloc} is the number of limbs currently allocated at @code{_mp_d},
-and naturally @code{_mp_alloc >= ABS(_mp_size)}.  When an @code{mpz} routine
+and normally @code{_mp_alloc >= ABS(_mp_size)}.  When an @code{mpz} routine
 is about to (or might be about to) increase @code{_mp_size}, it checks
 @code{_mp_alloc} to see whether there's enough space, and reallocates if
 @code{MPZ_REALLOC} is generally used for this.
+ at code{mpz_t} variables initialised with the @code{mpz_roinit_n} function
+or the @code{MPZ_ROINIT_N} macro have @code{_mp_alloc = 0} but can have a
+non-zero @code{_mp_size}.  They can only be used as read-only constants.
+See @ref{Integer Special Functions} for details.
 @end table

 The various bitwise logical functions like @code{mpz_and} behave as if



More information about the gmp-devel mailing list