Is this assert guaranteed to succeed, at least if T uses the default allocator?
T* p1 = new T;
T *p2 = new T[0];
assert( p1 != p2 ); // is this guaranteed?
In an article some years ago, I quoted the following from evidently some non-standard draft of 5.3.4/7, but the [Note] is not in the current standard:
> When the value of the expression in a direct-new-declarator is zero, the
> allocation function is called to allocate an array with no elements. The
> pointer returned by the new-expression is non-null. [Note: If the library
> allocation function is called, the pointer returned is distinct from the
> pointer to any other object.]
Neither James nor I can find current text – is this still guaranteed? If so, where does the standard say so?
And are replacement allocators allowed to return non-unique pointers in this case?
Thanks,
Herb
int x;
int* ptr = new int[0];
Is this assert guaranteed to succeed, at least if T uses the default allocator?
T* p1 = new T;
T *p2 = new T[0];
assert( p1 != p2 ); // is this guaranteed?
Is this assert guaranteed to succeed, at least if T uses the default allocator?
T* p1 = new T;
T *p2 = new T[0];
assert( p1 != p2 ); // is this guaranteed?
In an article some years ago, I quoted the following from evidently some non-standard draft of 5.3.4/7, but the [Note] is not in the current standard: