This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch] stl_vector.h


Dhruv Matani wrote:

Exactly, so a standard compliant allocator (user defined though) may do
weird stuff if n==0! We may not rely on such behaviour.


I don't read very often in the standard the word "weird" ;)
Seriously, the standard says only that "the return value is unspecified", not that
allocate can throw, or whatever. A standard compliant allocator shall return *any*
value, even zero, really "weird" value indeed, which is also ok.


Strictly, speaking then we *MUST* call deallocate for every such
allocate(0) call or it will be a faulty library(memory leak).


Indeed we do, whenever the first argument of _M_deallocate != 0, since it's, say,
"unlikely" ;) that the allocator leaks memory allocated at address zero ;)


Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]