This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [PATCH] Add configure flag for operator new (std::nothrow)


On 11/03/2015 04:08 PM, Mike Stump wrote:
On Nov 3, 2015, at 1:10 PM, Martin Sebor <msebor@gmail.com> wrote:
The "as if" requirement implies that any observable effects of
"the (possibly replaced) ordinary version" must be preserved.
The repeated calls to the new handler are among such effects.

Unless the standard is fixed to say that one cannot observe the repeated calls.  We do this in some places, for some things:

There are two sets of important observable effects: the calls to
the handler, and the call to the (possibly replaced) ordinary
operator new.

A C++ program is allowed to replace just the ordinary operator
new (and not the nothrow version), call the default nothrow
operator new, and expect to get back the same pointer that would
have been returned from the replaced new had it been called instead.
(Some implementations, including libstdc++, fail to conform to this
requirement.)

Changing the standard to remove the requirement to preserve these
effects would break the portability of programs that rely on it.

Martin


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