https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86822
Bug ID: 86822 Summary: attribute((malloc)) for new(nothrow) Product: gcc Version: 9.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Target Milestone: --- In decl.c:cxx_init_decl_processing, the C++ front-end predeclares ::operator new (normal or vector, aligned or not) and marks it with DECL_IS_MALLOC (opnew) = 1; This lets the compiler optimize various things: the result cannot alias, the result is seldom 0 (still under review), etc. The nothrow versions of operator new are only declared in <new> and do not have the equivalent __attribute__((__malloc__)). Unless someone can think of a reason not to, I think we should add it there.