mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-01-12 05:54:31 +08:00
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.
This commit is contained in:
parent
0bc199fc5d
commit
c227d96feb
@ -26,9 +26,6 @@
|
|||||||
#include <bits/exception_defines.h>
|
#include <bits/exception_defines.h>
|
||||||
#include "new"
|
#include "new"
|
||||||
|
|
||||||
using std::new_handler;
|
|
||||||
using std::bad_alloc;
|
|
||||||
|
|
||||||
extern "C" void *malloc (std::size_t);
|
extern "C" void *malloc (std::size_t);
|
||||||
|
|
||||||
_GLIBCXX_WEAK_DEFINITION void *
|
_GLIBCXX_WEAK_DEFINITION void *
|
||||||
@ -43,6 +40,13 @@ operator new (std::size_t sz, const std::nothrow_t&) noexcept
|
|||||||
}
|
}
|
||||||
__catch (...)
|
__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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user