3 ms·
> Well, since thread cancellation is implemented using exceptions, and thread cancellation can happen in arbitrary places, we’re always liable to a cancellation
by denotational 3y ago
> Well, since thread cancellation is implemented using exceptions, and thread cancellation can happen in arbitrary places, we’re always liable to a cancellation happening in a noexcept block, which is undefined behavior, and which in practice will cause your program to crash.
I believe the author is mistaken here: throwing an exception that reaches the end of a noexcept block is not undefined behaviour; it will call std::terminate per [except.spec] [1].
The linked mailing list post [2] makes no mention of UB, only that this might cause exceptions to be thrown unbeknownst to the programmer in implicitly-noexcept blocks (i.e. destructors) which now might need a noexcept(false) to avoid std::terminate (although that’s still not great because throwing from a destructor will likely lead to resource leaks even if it’s handled).
[1] https://timsong-cpp.github.io/cppwp/n4868/except.spec#5 https://timsong-cpp.github.io/cppwp/n4868/except.spec#5
[2] https://gcc.gnu.org/legacy-ml/gcc/2017-08/msg00121.html https://gcc.gnu.org/legacy-ml/gcc/2017-08/msg00121.html