From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18117 invoked by alias); 20 Jan 2014 21:36:46 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 18081 invoked by uid 48); 20 Jan 2014 21:36:41 -0000 From: "glisse at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: glisse at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-01/txt/msg02208.txt.bz2 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), 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++.