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++.