Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > stock unwinding from GotW #47

Reply
Thread Tools

stock unwinding from GotW #47

 
 
puzzlecracker
Guest
Posts: n/a
 
      05-01-2008
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
}
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open the stock Broking Franchisee of karvy Stock broking parvathi C++ 0 02-03-2009 06:48 AM
GotW #88: Is it safe to const_cast a reference to a temporary? Niels Dekker - no return address C++ 17 02-06-2008 10:52 AM
Challenging GotW 66's moral George2 C++ 4 12-27-2007 05:48 PM
How to add extra field(In stock/Out of stock) to a DropDownList ? savvy ASP .Net 1 06-28-2006 12:28 PM
Doubt in GotW #27 - forwarding functions Srini C++ 5 09-10-2005 10:26 PM



Advertisments