Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > stock unwinding...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 45685 of 47924
Post > Topic >>

stock unwinding from GotW #47

by puzzlecracker <ironsel2000@[EMAIL PROTECTED] > May 1, 2008 at 07:35 AM

It is per Sutter's GotW #47 article.  I don't understand why if a U
object is destroyed due to stack unwinding during to exception
propagation, T::~T will fail to use the "code that could throw" path
even though it safely could.

Code from the article:

   //  The wrong solution
    //
    T::~T() {
      if( !std::uncaught_exception() ) {
        // ... code that could throw ...
      } else {
        // ... code that won't throw ...
      }
    }


   //  Why the wrong solution is wrong
    //
    U::~U() {
      try {
        T t;
        // do work
      } catch( ... ) {
        // clean up
      }
    }
 




 1 Posts in Topic:
stock unwinding from GotW #47
puzzlecracker <ironsel  2008-05-01 07:35:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 6 17:04:01 CDT 2008.