[3.3] Followup to C++ forced unwinding

Richard Henderson rth@redhat.com
Thu May 1 00:20:00 GMT 2003


On Wed, Apr 30, 2003 at 04:50:53PM -0700, Nathan Myers wrote:
> Any thread can prevent cancellation by putting "while (true);" in
> a destructor.  Once control leaves the catch block, the thread can't 
> do any more externally visible work anyway, because that would touch 
> another cancellation point, which (I assume) would throw again.  

Yeah, but you have to work at it to not cancel the thread
(via exit or longjmp or infinite loop) from a destructor,
whereas it's easy to forget to rethrow inside a catch(...).

Thus, IMO destructors should be preferred over catch(...)
for *all* cleanup operations, not just for this cancellation
question.


r~



More information about the Gcc-patches mailing list