diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2020-10-28 13:19:21 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-10-28 13:19:21 +0000 |
commit | c227d96feb0030d63efad352b8fa7175b4c30721 (patch) | |
tree | b87884f6bb78d3d12e4e39de80b3ce37ee49601b | |
parent | 0bc199fc5d4eef5a20ced20df892e5e3b8821b60 (diff) | |
download | gcc-c227d96feb0030d63efad352b8fa7175b4c30721.zip gcc-c227d96feb0030d63efad352b8fa7175b4c30721.tar.gz gcc-c227d96feb0030d63efad352b8fa7175b4c30721.tar.bz2 |
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.
-rw-r--r-- | libstdc++-v3/libsupc++/new_opnt.cc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libstdc++-v3/libsupc++/new_opnt.cc b/libstdc++-v3/libsupc++/new_opnt.cc index ace4e6f..0e5e39a 100644 --- a/libstdc++-v3/libsupc++/new_opnt.cc +++ b/libstdc++-v3/libsupc++/new_opnt.cc @@ -26,9 +26,6 @@ #include <bits/exception_defines.h> #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; } } |