From: Marc Glisse <marc.glisse@inria.fr>
To: Mike Stump <mikestump@comcast.net>, Martin Sebor <msebor@gmail.com>
Cc: Daniel Gutson <daniel.gutson@tallertechnologies.com>,
Aurelio Remonda <aurelio.remonda@tallertechnologies.com>,
libstdc++@gcc.gnu.org,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
daniel.gutston@tallertechnologies.com,
Jonathan Wakely <jwakely.gcc@gmail.com>
Subject: Re: [PATCH] Add configure flag for operator new (std::nothrow)
Date: Wed, 04 Nov 2015 08:07:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.20.1511040853150.2317@laptop-mg.saclay.inria.fr> (raw)
In-Reply-To: <5639482B.1050309@gmail.com>
On Tue, 3 Nov 2015, 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:
[snip copy elision]
> in C++, so, it isnΒ’t out of the question. I was looking for dynamic ->
> static object optimization wording, but didnΒ’t find it in the first C++
> standard. That is a fairly reasonable thing to do, and if done well,
> can reasonably change the observable side-effects as well.
There is recent-ish wording in [expr.new] that says that 'new int' is not
forced to call operator new. However, operator new (which can be called
directly) has a rather strictly defined behavior. And a bad one at that,
since it forces the use of an exception to report an error to the direct
caller...
On Tue, 3 Nov 2015, Martin Sebor wrote:
> There are two sets of important observable effects: the calls to
> the handler, and the call to the (possibly replaced) ordinary
> operator new.
"This nothrow version of operator new returns a pointer obtained as if
acquired from the (possibly replaced) ordinary version."
For a non-native speaker, it is extremely unclear if the (possibly
replaced) ordinary version is the original one that has been displaced or
if it is the user one that did the replacement.
> 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.)
That's also the interpretation I remember, and I find it contradictory
with the C++ philosophy that exceptions are heavy, expensive, and should
be avoided for local use. (of course allocation failure should be rare)
--
Marc Glisse
next prev parent reply other threads:[~2015-11-04 8:07 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-03 12:35 Aurelio Remonda
2015-11-03 13:26 ` Paolo Carlini
2015-11-03 14:06 ` Aurelio Remonda
2015-11-03 14:12 ` Andreas Schwab
2015-11-03 17:17 ` Aurelio Remonda
2015-11-03 20:25 ` Martin Sebor
2015-11-03 20:41 ` Daniel Gutson
2015-11-03 21:10 ` Martin Sebor
2015-11-03 23:09 ` Mike Stump
2015-11-03 23:50 ` Martin Sebor
2015-11-04 8:07 ` Marc Glisse [this message]
2015-11-04 6:20 ` Jonathan Wakely
2015-11-04 6:32 ` Jonathan Wakely
2015-11-05 15:22 ` Daniel Gutson
2015-11-05 17:11 ` Jonathan Wakely
2015-11-05 18:01 ` Daniel Gutson
2015-11-06 1:56 ` Jonathan Wakely
[not found] ` <CAF5HaEVF12CH+Z6BssUwmS-TVxGsjfXWdvvGUZ2OHuUhOhhwHA@mail.gmail.com>
2015-11-06 4:24 ` Jonathan Wakely
2015-11-06 7:19 ` Marc Glisse
2015-11-06 9:59 ` Pedro Alves
2015-11-10 13:10 ` Jonathan Wakely
2015-11-16 18:56 ` Pedro Alves
2016-02-19 21:56 ` Daniel Gutson
2016-02-22 15:58 ` Jonathan Wakely
2016-02-19 21:45 ` Daniel Gutson
2015-11-17 12:38 ` Sebastian Huber
2015-11-04 6:15 ` Jonathan Wakely
2015-11-04 14:52 ` Martin Sebor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.20.1511040853150.2317@laptop-mg.saclay.inria.fr \
--to=marc.glisse@inria.fr \
--cc=aurelio.remonda@tallertechnologies.com \
--cc=daniel.gutson@tallertechnologies.com \
--cc=daniel.gutston@tallertechnologies.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jwakely.gcc@gmail.com \
--cc=libstdc++@gcc.gnu.org \
--cc=mikestump@comcast.net \
--cc=msebor@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).