Right now, operator new() will throw if memory allocation fails.
The idea is that in theory your application can catch these exceptions and properly clean up. In practice, almost nobody actually handles memory allocation exceptions. Most of the time there is no way to handle it properly. Aside from very small carefully controlled situations, its impossible to unit test what happens when each and every allocation fails. If your application runs of memory you're better off just crashing.
The consequence of this design decision, is that everything that might do a memory allocation needs to be exception safe. We need to write exception safe code and the compiler must also assume any allocation can throw and then setup the unwinding structures.
A good example of this, would be something like vector::push_back(). If push_back needs to reallocate, it will move construct each element. If move can throw, it will need to fallback to copy. If copy can throw, there needs to be cleanup code in place that will destroy all of the previously copied elements and deallocate the new buffer. Finally, for the programmer calling push_back. I need to be sure to order the other stuff before and after it correctly, so my state doesn't get messed up in the off chance that it throws.
For the case of allocations, all of this exception cleanup code is in practice dead code. It increases our binary size which also negatively impacts the Icache.
Most compilers provide some variant of -fno-exceptions which entirely disables exceptions for a performance gain. But what if we want to use exceptions carefully in a few places but not suffer the cost of them globally from allocations?
So the idea is to have some way to make operator new() noexcept at compile time. Probably via a #define. This differs from the nothrow version of new because it actually calls std::terminate() if the allocation fails, instead of returning nullptr. No only can the compiler assume new will never throw, it could also assume it never returns a nullptr.
Also this approach is better than using an allocator. You just switch it on and everything works. ABI compatibility should not be a problem as separately compiled code can be compiled with or without the feature. For any opaque function call that isn't noexcept, we still need to assume it can throw anything. This optimization would only be possible in inline context.
This noexcept new mode could also improve application correctness. Almost nobody ever writes careful code to handle exceptions thrown by new.
People can write catch blocks for std::exception anticipating other errors. This will catch allocation errors as well. Since its impossible to unit test every possible allocation site, its unlikely to be handled properly. It would be better to just crash at the allocation site, with a ready stack trace for debugging.
At a minimum, most people write try {} catch {} blocks around the entire application in main. This completely obscures the source of an exception, especially an out of memory error which could happen almost anywhere.
If I accidentally try to allocate INT_MAX somewhere, I'd rather get a core dump at the site of the bug than a clean exit from main in a catch{} block.
I don't have hard data on any of this, but I suspect the following things are likely true:
1. Most C++ applications don't need to handle out of memory conditions and just calling std::terminate() immediately at the allocation site is the best possible solution.
2. The largest source of "possibly can throw" in most applications come from things that *might* allocate memory. Mostly from std:: containers.
3. This mode could give us most of the performance benefits of -fno-exceptions while still allowing us to use exceptions in certain parts of the system.
4. This mode can help us make our systems much simpler and more correct, as we don't have to worry about the effectively infinite explosion of possible application states from throwing allocations.
5. After removing allocations from concern, tools that analyse how exceptions are used in programs might actually be meaningful and possible.
Would you use noexcept new in any of your applications?