operator new/delete forwarding
Howard Hinnant
hhinnant@apple.com
Tue May 1 17:14:00 GMT 2007
On May 1, 2007, at 11:56 AM, Martin Sebor wrote:
> I wasn't aware of the use case given in N2158, or the requirement
> for operator delete(void*) to be able to handle pointers obtained
> from both the throwing as well as the nothrow overloads of operator
> new (I just found it in [basic.stc.dynamic.deallocation], p3). It
> seems to me that mixing and matching calls to a throwing new and
> a nothrow delete (or vice versa) is at the root of the problem and
> should not be allowed. Wouldn't that be an easier way to solve the
> issue?
I don't think so. Saying new (nothrow) followed by delete has been
the normal usage pattern for new(nothrow) for nearly a decade now.
Saying that no longer works would be a fairly massive breakage of
existing code. One doesn't have to search the net long at all to
find many examples of such code as the proper way to use new
(nothrow). The C++98 intent is that operator delete(void*,nothrow)
is never called explicitly by the coder, but only used by the
compiler in the case that a constructor within a new(nothrow)
expression throws an exception:
struct A
{
A() {throw 1;}
};
void foo()
{
A* p = new (std::nothrow) A; // calls delete(void*, nothrow),
then propagates exception
delete p; // would have been ok had A() not thrown
}
> As for the pace we're at which we deal with issues, I have no
> problem with it. I am, however, less than fully comfortable with
> straw polls of a handful of people who just happen to be in the
> room at the time determining the outcome of issues. I wish we
> had a more accessible process in place, such as online polls.
> Austin Group has a mechanism like that in place:
> http://www.opengroup.org/austin/interps/faq_polls.tpl
> We could use one of the many online polling services or set up
> our own.
I do occasionally ask for opinions on various subjects on the
std::lib reflector. However even in those cases, the LWG straw polls
taken in person at the meetings still guide the LWG's recommendation
to the full committee. And the full committee votes taken among J16
voting members, and WG21 voting members are the only *binding* votes
that can be taken (whether or not the result of that vote reflects
the LWG's recommendation - which it sometimes does not).
-Howard
More information about the Libstdc++
mailing list