This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Placement new[] weirdness
- To: egcs at egcs dot cygnus dot com
- Subject: Placement new[] weirdness
- From: Andrey Slepuhin <pooh at msu dot ru>
- Date: Thu, 15 Jul 1999 18:40:22 +0400 (MEDT)
- Organization: Moscow State University Network (MSUnet)
Hi,
We have the following in C++ draft, clause 5.3.4:
12[Example:
--new T results in a call of operator new(sizeof(T)),
--new(2,f) T results in a call of operator new(sizeof(T),2,f),
--new T[5] results in a call of operator new[](sizeof(T)*5+x), and
--new(2,f) T[5] results in a call of
operator new[](sizeof(T)*5+y,2,f).
Here, x and y are non-negative, implementation-defined values repre-
senting array allocation overhead. Their value might vary from one
invocation of new to another. ]
This means that a call of placement new[] operator
new(p) T[N];
returns p+x, where x is some implementation-defined constant.
This makes placement new[] operator totally useless.
>From the other point, in C++ draft, clause 18.4.1.3:
void* operator new[](std::size_t size, void* ptr) throw();
Returns:
ptr.
Notes:
Intentionally performs no other action.
I.e. this contradicts to the previous description.
Can anybody check the final standard about this?
Indeed, I can imagine a correct implementation of placement new[]
which has zero overhead for array length (though such implementation
may have perfomance loss).
Regards,
Andrey.