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)
Hi Nathan,
This may be out of context... The standard defines that allocators
(and operator new) may be asked for zero bytes. They must return an
address different from any other address that they have returned that
haven't since been released. (That disallows returning 0.) Most
implementations treat a call to operator new(0) identically to operator
new(1).
I'm pretty sure we already briefly discussed this corner case. I think the
behavior of 3.3 (returning *always* zero in this case), is perfectly ok,
because of this note in Table 32, about allocate:
"Note: If n == 0, the return value is unspecified."
Paolo.