public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/59894] New: Force use of the default new/delete
Date: Mon, 20 Jan 2014 21:36:00 -0000	[thread overview]
Message-ID: <bug-59894-4@http.gcc.gnu.org/bugzilla/> (raw)

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59894

            Bug ID: 59894
           Summary: Force use of the default new/delete
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org

Hello,

operator new and operator delete are hidden in libsupc++ so they can be easily
replaced, either directly in the code, or later by interposing a library. Doing
so has a cost, and I have seen people (and done it myself) providing a
definition in their code that was roughly equivalent to the standard one, just
so it could be inlined.

I wonder if we could provide a flag in libstdc++ so that if the user compiles
his code with -D_GLIBCXX_FORCE_DEFAULT_ALLOCATION (a better name would be
welcome), <new> defines inline versions of the operators. We might even want to
skip new_handler in that version, I am not sure.

I didn't think too long about the possible drawbacks, but defining the macro
would be a pretty clear message from the user that he takes full responsibility
for all the consequences.

(we are also using, in the same code, extern "C" __typeof(malloc) malloc
__attribute__((returns_nonnull)); so it really simplifies, but PR 59875 shows
that simplifying operator delete(0) would already be nice)

PR 59893 considers a different path using LTO to inline at link time the
definition from libsupc++.


             reply	other threads:[~2014-01-20 21:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-20 21:36 glisse at gcc dot gnu.org [this message]
2014-01-20 21:57 ` [Bug libstdc++/59894] " trippels at gcc dot gnu.org
2014-01-20 22:07 ` glisse at gcc dot gnu.org
2014-01-21  9:40 ` redi at gcc dot gnu.org
2014-02-24 14:01 ` glisse at gcc dot gnu.org

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=bug-59894-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).