This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add configure flag for operator new (std::nothrow)


On 4 November 2015 at 02:11, Daniel Gutson wrote:
> Since this is a nothrow new, we thought that probably the system
> might not be exceptions-friendly (such as certain embedded systems),
> so we wanted to provide the new_handler the ability to do something else
> other than trying to allocate memory and keep the function iterating.

That could be done using an alternative overload of operator new
instead of altering the semantics of the standard one (that could be
provided as a GNU extension, for example).

> In fact, our idea is that since the nothrow new can indeed return nullptr,
> let the new_handler do something else and leave the no-memory-consequence
> to the caller.
> This new flag enables just that.


The default configuration already allows the caller to deal with
allocation failure from the nothrow version of new, by not installing
a new-handler installed, and dealing with a null return value. How
would I use this alternative configuration? Since the behaviour only
changes when a new-handler is installed, presumably I'm meant to
install some kind of new-handler that does something else ... but
what? The patch should include documentation explaining when and how
to use this option.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]