I was lucky enough to be part of a spirited email discussion recently on the topic of exceptions. And luckier still that Diego Dagum, the new C++ Community PM, has
summarized it on the VC team blog. You should enjoy reading the "best practices" we worked our way around to, like:
Most MVPs agreed that, despite not being illegal in C++, throwing primitive
types like int, long, etc., or similarly Windows-based
ones like HRESULT, etc. is a
coding horror as inabilities to catch those in the proper place will make the
application crash with a hard post-investigation to determine where they are
being originated.
Of course, we ended up talking about checked exceptions, one of the things I really hated about Java personally, and RAII which is a critical way of thinking if there are exceptions flying around your app. STL joins in with a comment that could be worth gold to someone dealing with SEH:
I strongly recommend AGAINST using the /EHa compiler option. Either /EHs or
/EHsc should ALWAYS be used, with /EHsc being preferable (it's faster because it
assumes that extern "C" functions won't emit exceptions - while technically
permitted by the Standard, sane code should never attempt to do such a thing, so
giving up that ability is worth the performance gain).
And I am sure the comments will continue to grow and the conversation continue. This is how we all get better, by discussing and sharing and occasionally defending our practices. It's a must-read.
Kate