This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Placement new[] weirdness


Andrey Slepuhin wrote:

> Hi,
>
> We have the following in C++ draft, clause 5.3.4:
>
> 12[Example:

[...]

> 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.

I wouldn't call that a contradiction. It's just that the placement
"overload"
of new[] behaves differently. Think template spacialisation.

> Can anybody check the final standard about this?

Yep, it's there, with the same wording.

> Indeed, I can imagine a correct implementation of placement new[]
> which has zero overhead for array length (though such implementation
> may have perfomance loss).

But you can't overload the new[] operator, you can only overload "operator
new[]", which is not the same thing. "new(p) t[]" is magic, it doesn't call
"operator new[]".

    Brane

--
Branko Čibej                 <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
voice: (+386 61) 186 53 49   fax: (+386 61) 186 52 70



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]