The draft C++11 standard says
Unless an object is a bit-field or a base class subobject of zero size, the address of that object is the address of the first byte it occupies. Two objects that are not bit-fields may have the same address if one is a subobject of the other, or if at least one is a base class subobject of zero size and they are of different types; otherwise, they shall have distinct addresses. (1.8(6))
However, earlier it says an object can be created by a new
expression, and it's conceivable that a new
expression could cause a user-defined operator new()
to be called that could return the address of some char[]
block it's reserved for this purpose (the first allocation could return the first address of the block), which would mean there are two objects that do not have distinct addresses (the one created by new
and the char[]
block). Does 1.8(6) mean that it's illegal for a user-defined new
to work this way? Or is it just a hole in the language definition?