This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Add configure flag for operator new (std::nothrow)
- From: Martin Sebor <msebor at gmail dot com>
- To: Mike Stump <mikestump at comcast dot net>
- Cc: Daniel Gutson <daniel dot gutson at tallertechnologies dot com>, Aurelio Remonda <aurelio dot remonda at tallertechnologies dot com>, libstdc++ at gcc dot gnu dot org, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, daniel dot gutston at tallertechnologies dot com, Jonathan Wakely <jwakely dot gcc at gmail dot com>
- Date: Tue, 03 Nov 2015 16:50:03 -0700
- Subject: Re: [PATCH] Add configure flag for operator new (std::nothrow)
- Authentication-results: sourceware.org; auth=none
- References: <1446554133-3090-1-git-send-email-aurelio dot remonda at tallertechnologies dot com> <56391843 dot 1070807 at gmail dot com> <CAF5HaEVeD4G1Mj8GwbpLyZ8V+GWNRAy1=5qbfVHgrZ=GpkbHbg at mail dot gmail dot com> <563922C6 dot 7080706 at gmail dot com> <3937336D-6170-4513-A658-A2835E87FB0C at comcast dot net>
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