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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: operator new/delete forwarding


On Jul 20, 2006, at 1:20 PM, Howard Hinnant wrote:

We currently have:

operator new forwards to malloc. operator delete forwards to free.
operator new(nothrow) forwards to malloc. operator delete(nothrow) forwards to free.
operator new [] forwards to operator new. operator delete [] forwards to operator delete.
operator new(nothrow)[] forwards to operator new(nothrow). operator delete(nothrow)[] forwards to operator delete.

While writing up the proposed resolution for:


http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#206

I noticed that the working paper already clearly says:

operator new [] forwards to operator new. operator delete [] forwards to operator delete.
operator new(nothrow)[] forwards to operator new(nothrow). operator delete(nothrow)[] forwards to operator delete(nothrow).


This is a slight change from C++03, modified by lwg 298 with WP status:

http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#298

Though I had early proposed:

operator new(nothrow)[] forwards to operator new[]. operator delete (nothrow)[] forwards to operator delete[].

I see no problem with the WP's existing:


operator new(nothrow)[] forwards to operator new(nothrow). operator delete(nothrow)[] forwards to operator delete(nothrow).

I'm bringing this to the attention of this list because we had decided to wait and see how lwg 206 turned out. Lwg 206 isn't going to recommend a change to operator delete(nothrow)[]. Therefore I recommend that libstdc++ change at its earliest convenience to have delete(nothrow)[] forward to delete(nothrow) instead of to delete.


Change del_opvnt.cc from:

_GLIBCXX_WEAK_DEFINITION void
operator delete[] (void *ptr, const std::nothrow_t&) throw ()
{
  ::operator delete (ptr);
}

to:

_GLIBCXX_WEAK_DEFINITION void
operator delete[] (void *ptr, const std::nothrow_t& t) throw ()
{
  ::operator delete (ptr, t);
}

The only change lwg 206 is going to recommend is:

operator new(nothrow) forwards to operator new. operator delete(nothrow) forwards to operator delete.

on which we can still wait for the lwg's decision.

-Howard


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