title: why cannot use uncaught_exception in dtor?
body: <p>Herb Sutter in his article <a href="http://www.gotw.ca/gotw/047.htm" rel="nofollow">http://www.gotw.ca/gotw/047.htm</a> 
  pointed out that we cannot use  uncaught_exception in desturctor function,</p>
  
  <pre><code>//  Why the wrong solution is wrong
  //
  U::~U() {
    try {
      T t;
      // do work
    } catch( ... ) {
      // clean up
    }
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>but I write a test program, and T::~T in fact didn't use the "code that could throw" </p>
  
  <pre><code>#include &lt;exception&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  class T {
    public:
    ~T() {
    if( !std::uncaught_exception() )
    {
      cout&lt;&lt;"can throw"&lt;&lt;endl;
      throw 1;
    } else
    {
      cout&lt;&lt;"cannot throw"&lt;&lt;endl; 
    }
  }
  
  
  };
  
  struct U
  {
  ~U() {
    try 
    {
      T t;
    }
    catch( ... ) 
    {
    }
  }
  };
  
  void f()
  {
    U u;
    throw 2;
  } 
  
  int main()
  {
      try
      {
        f();
      }
      catch(...)
      {}
  }
  </code></pre>
  
  <p>output is :
  cannot throw</p>
  
  <p>did I miss something?</p>
  
  <p>Thanks</p>