gmp-4.1.2 assertion failure
Torbjorn Granlund
tg at swox.com
Tue Feb 17 11:45:30 CET 2004
Kevin Ryde <user42 at zip.com.au> writes:
> + {
> + /* this block is equivalent to
> + ralloc = (bsize * GMP_NUMB_BITS - cnt + GMP_NAIL_BITS) * e / GMP_NUMB_BITS + 5;
> + MPZ_REALLOC(r,ralloc+rtwos_limbs);
> + but without any overflow problems
> + */
This is not too pretty, but I suppose there's no alternative.
If this is about the mpz_*pow* size overflow, the suggested 30 line
replacement is not OK. I would like to look for alternatives.
We don't need to cap result size at 2^32 (for a 32-bit machine).
It is OK to cap it at 2^29 or less, since that will fill the
entire memory.
I wouldn't mind seeing an ASSERT which does the calculation another
way, like dividing ULONG_MAX by the bsize stuff to work out a limit
for the exponent.
Division by a non-invariant takes 10 to 100 cycles on current machines.
--
Torbjörn
More information about the gmp-bugs
mailing list