Subject: Re: [boost] Noexcept
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2017-06-13 02:19:38
On 13/06/2017 12:42, Emil Dotchevski wrote:
>>> If unhandled errors remain at the time the current thread terminates,
>>> Noexcept calls abort(). Use catch_<> to handle any error regardless
>>> of its type.
>> Shouldn't it call std::terminate() instead?
> I think abort() is better because it would be strange for a program that
> doesn't use exceptions to indicate an unhandled exception. :) But maybe it
> would be more practical to call terminate(), I'm not sure.
std::terminate() isn't just for unhandled exceptions, though (eg. it's
also called for unjoined threads). And this still kind of is an
unhandled exception anyway.
Using std::terminate() allows hooking std::set_terminate() to trigger
logging or minidump/coredump, which can be useful. (abort() can be
similarly intercepted via SIGABRT, but it's a more restricted context.)
Or to put it another way: std::terminate() is C++; abort() is C. It
seems wrong to use the C-based termination method in a C++ context.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk