Lazy mpz allocation
tg at gmplib.org
Mon Aug 31 19:20:43 UTC 2015
nisse at lysator.liu.se (Niels Möller) writes:
tg at gmplib.org (Torbjörn Granlund) writes:
> (We should use 'attribute ((visibility ("hidden")))' for the the
> constant zero limbs at any rate. I'll commit a basic patch for that
Maybe it should have a more interesting value than zero, to help catch
bugs if it is used when it shouldn't. And when running valgrind, it
could be explicitly marked as readable but undefined, to generate
valgrind warnings if any branch or memory access depends on the value.
Unfortunately, the manual sayd "Initialize x, and set its value to 0."
It's tempting to try to rely on it being zero, like eliminating the
_mp_size != 0 test in mpz_odd_p, but that's broken unless all code that
may assign zero to _mp_size makes sure that _mp_size == 0 implies
_mp_d == 0, which I doubt is a good idea.
I don't think we do that, nor should we.
Please encrypt, key id 0xC8601622
More information about the gmp-devel