This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: valgrind confused by std::allocator calls to operator new(0)
On Tue, Feb 22, 2005 at 02:40:04PM +0100, Gabriel Dos Reis wrote:
> Michael Veksler <VEKSLER@il.ibm.com> writes:
>
> | Is it possible/reasonable to change new_allocator::allocate such that
> | it returns NULL when __n ==0 ? Should I open a PR against libstdc++?
>
> Yes, please.
No, the bug is in valgrind, because zero arguments to the allocators
are explicitly allowed. If we choose to work around the valgrind bug,
the workaround belongs in std::vector, not in the allocators. (It is
a minor optimization, anyway, to avoid performing an allocation when
copying an empty vector.)
Nathan Myers
ncm@cantrip.org