I was wondering… what if when you do a new, the address where the reservation starts is 0x0? I guess it is not possible, but why?
is the new operator prepared for that? is that part of the first byte not usable? it is always reserved when the OS starts?
Thanks!
The null pointer is not necessarily address
0x0, so potentially an architecture could choose another address to represent the null pointer and you could get0x0fromnewas a valid address. (I don’t think anyone does that, btw, it would break the logic behind tons ofmemsetcalls and its just harder to implement anyway).Whether the null pointer is reserved by the Operative System or the C++ implementation is unspecified, but plain
newwill never return a null pointer, whatever its address is (nothrownewis a different beast). So, to answer your question:Maybe, it depends on the particular implementation/architecture.