C++ Exceptions: Under the Hood (2013)
Working with and implementing C++ exceptions for 30 years now, including implementing exception handling for Windows, DOS extenders, and Posix (all very different), and then re-implementing them for D, I have sadly come to the conclusion that exceptions are a giant mistake.<p>1. they are very hard to understand all the way down<p>2. they are largely undocumented in how they&#x27;re implemented<p>3. they are slow when thrown<p>4. they are slow when not thrown<p>5. it is hard to write exception-safe code<p>6. very few understand how to write exception-safe code<p>7. there is no such thing as zero-cost exception handling<p>8. optimizers just give up trying to do flow analysis in try-exception blocks<p>9. consider double-fault exceptions - there&#x27;s something that shows how rotten it is<p>10. has anyone yet found a legitimate use for throwing an `int`?<p>I have quit using exceptions in my own code, making everything &#x27;nothrow&#x27;. I regret propagating exception handling into D. Constructors that may throw are an abomination. Destructors that throw are even worse.