This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Placement new[] weirdness
- To: Andrey Slepuhin <pooh at msu dot ru>
- Subject: Re: Placement new[] weirdness
- From: Branko Cibej <branko dot cibej at hermes dot si>
- Date: Fri, 16 Jul 1999 09:05:13 +0200
- CC: egcs at egcs dot cygnus dot com
- Organization: HERMES SoftLab
- References: <XFMail.990716105721.pooh@msu.ru>
Andrey Slepuhin wrote:
> On 16-Jul-99 Branko Cibej wrote:
> > Andrey Slepuhin wrote:
> >
> >> 2) However we still can call placement delete[] by
> >> typing operator delete (p,p). ...
> >
> > I think you're confusing destruction and deallocation.
> > They're not interchangeable.
>
> Yes I know. But indeed, there is something weird with new[] and delete[]:
> when you are using operator+, you can write
> both a+b and operator+(a,b). They are identical.
>
> new[] and delete[] are differ. Why? If the compiler
> catch expressions like "delete[] p;", calls object destructors,
There's the catch. the _compiler_ calls object destructors ...
> and then calls *deallocation* function, why it cannot catch
... and the deallocation function is called `operator delete'.
> expressions like "operator delete[](p);" and do the same thing?
Ah, you're looking for consistence in C++? Optimist! ;-)
> Or may be I'm not garanteed that a+b and operator+(a,b)
> are identical?
Yes, that's guaranteed.
As I mentioned in a earlier post, the `new', `new[]',
`delete' and `delete[]' operators are magic in C++
-- as oposed to `operator new', etc. What's confusing is
that the names are so similar: `new' <-> `operator new',
but that doesn't change the fact that their semantics are
different. It's just something you have to live with.
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