Possible Duplicate:
what does malloc(0) return ?
Does it return zero pointer? Is the behavior standardized?
How about STL allocator?
I googled it, but couldn't pinpoint the answer I was looking for.
EDIT: The linked question doesn't explain STL allocator.
I have another relevant question. What happens if one tries to deallocate zero pointer?
allocator.deallocate(0, 1);
malloc(0)
may either return 0 or it may return a unique address (which shall not be accessed) -- the C89 and C99 Standards allow either behavior but do not mandate either one. (Bad design for a standard and I objected when I was on X3J11 but that's how it is.)
BTW, this is a duplicate question: what does malloc(0) return?
Tested on Linux 2.6.34.7-66.fc13.x86_64, it returns a unique address.
I wouldn't try to dereference it though. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With