This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: operator new/delete forwarding
- From: Howard Hinnant <hhinnant at apple dot com>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Thu, 9 Nov 2006 14:14:37 -0500
- Subject: Re: operator new/delete forwarding
- References: <28E2CC50-386A-47DC-8A47-29357E013744@apple.com>
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