<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Where are we going, and what's with the handbasket? : c++</title><link>http://blogs.msdn.com/dcook/archive/tags/c_2B002B00_/default.aspx</link><description>Tags: c++</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Exceptional wisdom</title><link>http://blogs.msdn.com/dcook/archive/2007/03/28/exceptional-wisdom.aspx</link><pubDate>Thu, 29 Mar 2007 09:09:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:1985176</guid><dc:creator>dcook</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/dcook/comments/1985176.aspx</comments><wfw:commentRss>http://blogs.msdn.com/dcook/commentrss.aspx?PostID=1985176</wfw:commentRss><description>&lt;P&gt;In Visual C++ 7.1 and earlier, "catch(...)" would catch all exceptions, both C++ and SEH. The behavior has changed with Visual C++ 8.0. This has caused some confusion.&lt;/P&gt;
&lt;P&gt;The details get a bit tricky, but the generally accepted wisdom among the C++ gurus that have advised me is:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;try/catch is for C++ exceptions.&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;Corollary: Don't catch C++ exceptions with __except.&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;__try/__except is for Windows Structured Exception Handling (SEH) exceptions.&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;Corollary: Don't catch SEH exceptions with catch.&lt;/LI&gt;
&lt;LI&gt;Corollary: Don't use _set_se_translator. Use __except, then throw your C++ exception from the __except block.&lt;/LI&gt;
&lt;LI&gt;Corollary: Don't use /EHa. The only reason to use /EHa is to catch SEH exceptions with catch or via _set_se_translator, which you shouldn't be doing in the first place.&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;Don't use both C++ exception handling and SEH exception handling in the same function.&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;Creating an instance of an object that has a destructor implicitly generates a try/catch block, so don't create destructable objects in a function that uses __try/__except or might directly raise an SEH exception.&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;Don't catch anything you don't know how to handle.&lt;/LI&gt;
&lt;LI&gt;You don't know how to handle Access Violations.&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;Corollary: Don't catch Access Violations. Ever.&lt;/LI&gt;&lt;/UL&gt;
&lt;LI&gt;It was always kind of weird (many would say horrible and bad) that the C++ catch would &lt;STRONG&gt;sometimes&lt;/STRONG&gt; catch SEH exceptions. This was never dependable. Don't rely on this behavior.&lt;/LI&gt;
&lt;LI&gt;It is a compiler implementation detail that __except can catch C++ exceptions. Don't rely on this behavior.&lt;/LI&gt;
&lt;LI&gt;Visual C++ 8.0 changed the semantics of "catch(...)".&lt;/LI&gt;
&lt;UL&gt;
&lt;LI&gt;catch(...) no longer catches all SEH exceptions. This is a good thing (see rules 4 and 5).&lt;/LI&gt;
&lt;LI&gt;If you were following the above rules, you didn't see any changes in your program's behavior.&lt;/LI&gt;&lt;/UL&gt;&lt;/OL&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1985176" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/dcook/archive/tags/c_2B002B00_/default.aspx">c++</category></item></channel></rss>