Zero-overhead deterministic exceptions: Throwing values [pdf]
This paper suggests that people avoid C++ exceptions due to some problem with dynamic allocation or unpredictable cost or something. Maybe that&#x27;s true in hard real-time circles, but in my day-to-day experience with C++ exception avoidance , I see very little rationality going into the decision.<p>I am continually frustrated by people who refuse to use C++ exceptions. These people claim to have a &quot;philosophical objection&quot; to the &quot;unusable&quot; exception model. They continually cite &quot;bad&quot; exception code involving try-catch clauses at every stack frame (which nobody actually writes), they claim that C++ exception handling produces &quot;undefined&quot; behavior (it doesn&#x27;t), or that compiler support is somehow buggy (it isn&#x27;t). These arguments <i>make no sense</i>. They have no persuasive power. They do not intersect with the real world.<p>Best of all, these very serious people, having written very sagacious emails banning random parts of C++ and having intoned that horrible things happen if one allows non-local flow control, switch from their email clients to their editors and go on to write Python and Java! Somehow, exceptions are cripplingly unusable in C++ yet not worth writing home about when used in Python or Java.<p>My theory is that most opposition to C++ exception usage is motivated mostly by cargo-culting and that most of the supposed arguments against exceptions are post-hoc rationalizations of a decision already made on the basis of non-technical factors. To wit: there were real performance and correctness problems with exceptions in early 1990s C++ compilers. These problems have been resolved for a very long time. Yet the 1990s meme that to be a <i>responsible</i> programmer, one should disable exceptions, or at best &quot;use exceptions for exceptional situations&quot; comes down to us in the present day. Too often, people blindly follow advice without seriously considering it, and it seems more likely that random bans on C++ exceptions demonstrate this phenomenon than any legitimate technical disagreement.