[committed] libstdc++: Add comment to nothrow new explaining catch (...)
Jonathan Wakely
jwakely@redhat.com
Wed Oct 28 13:19:48 GMT 2020
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.
Tested powerpc64le-linux. Committed to trunk.
-------------- next part --------------
commit c227d96feb0030d63efad352b8fa7175b4c30721
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Oct 28 13:19:21 2020
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 <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;
}
}
More information about the Gcc-patches
mailing list