LLVM treats reaching a state which would throw an exception as an immediate crash. If the implementation / compilation settings used enable exceptions, one is thrown unwinds and finds no catch handler and calls std::terminate
. If the implementation / compilation settings disable exceptions, the implementation must provide some alternative behavior. Most will crash immediately in one way or another.
Developers on LLVM test their code with exactly these settings and are careful to avoid circumstances that could potentially throw.
One circumstance which is impossible to avoid directly is allocation failures. LLVM simply does not support platforms where allocations may fail and the user have to catch bad_alloc
. If the platform fails to allocate memory at any point, LLVM will crash.
It turns out that the vast majority of non-embedded platforms today use some form of overcommit. And due to the nature of how LLVM is engineered, we have no particularly useful mechanism available to respond gracefully to a failure to allocate memory. As a consequence, it is considered a fatal and irrecoverable error, and whether we enable exceptions or not, we're going to terminate the process at that point.