From: Jonathan Wakely Date: Wed, 28 Oct 2020 13:19:21 +0000 (+0000) Subject: libstdc++: Add comment to nothrow new explaining catch (...) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c227d96feb0030d63efad352b8fa7175b4c30721;p=gcc.git libstdc++: Add comment to nothrow new explaining catch (...) The decision to not rethrow a __forced_unwind exception is deliberate, so add a comment explaining it. libstdc++-v3/ChangeLog: * libsupc++/new_opnt.cc (new): Add comment about forced unwind exceptions. --- diff --git a/libstdc++-v3/libsupc++/new_opnt.cc b/libstdc++-v3/libsupc++/new_opnt.cc index ace4e6f9345..0e5e39ab994 100644 --- a/libstdc++-v3/libsupc++/new_opnt.cc +++ b/libstdc++-v3/libsupc++/new_opnt.cc @@ -26,9 +26,6 @@ #include #include "new" -using std::new_handler; -using std::bad_alloc; - extern "C" void *malloc (std::size_t); _GLIBCXX_WEAK_DEFINITION void * @@ -43,6 +40,13 @@ operator new (std::size_t sz, const std::nothrow_t&) noexcept } __catch (...) { + // N.B. catch (...) means the process will terminate if operator new(sz) + // exits with a __forced_unwind exception. The process will print + // "FATAL: exception not rethrown" to stderr before exiting. + // + // If we propagated that exception the process would still terminate + // (because this function is noexcept) but with a less informative error: + // "terminate called without active exception". return nullptr; } }