_mp_alloc vs ALLOC
Marc Glisse
marc.glisse at inria.fr
Sat Jun 9 14:44:04 CEST 2012
On Sat, 9 Jun 2012, bodrato at mail.dm.unipi.it wrote:
>> Won't valgrind complain about an uninitialized read here?
>
> It shouldn't! I read from the manual of Valgrind:
> http://valgrind.org/docs/manual/mc-manual.html#mc-manual.uninitvals
>
> "It is important to understand that your program can copy around junk
> (uninitialised) data as much as it likes. [...] A complaint is issued only
> when your program attempts to make use of uninitialised data in a way that
> might affect your program's externally-visible behaviour."
>
> So, if the value is correctly overwritten before using it, Valgrind should
> not complain.
Cool, I did not know that, thanks!
> I inserted the line for testing purposes, but it obviously is useless, it
> can be removed!
No, no, looks good :-)
>> I think mpz_neg is a candidate for MPZ_NEWALLOC.
>
> I think there are many, because the macro destroys the content only if a
> memory enlargement is needed. E.g. mpz/tdiv_?_2exp.c are candidate for
> _NEWALLOC, because no reallocation (i.e. no data loose) happen when source
> and destination operands coincide.
Good. I wanted to make sure before adding some (not that that will happen
anytime soon...).
--
Marc Glisse
More information about the gmp-devel
mailing list