[RFC] C++ vs forced unwinding

Mike Harrold mharrold@cas.org
Mon Apr 7 15:29:00 GMT 2003


Fergus Henderson wrote:
> 
> On 07-Apr-2003, Mark Mitchell <mark@codesourcery.com> wrote:
> > 
> > FWIW, I don't think "throw ()" should have any affect here.  Cancelling a
> > thread is not throwing an exception, implementation similarities aside.
> 
> Well, the downside of that approach is that it's already too hard to
> write exception-safe code (beyond the ability of most programmers).
> When you introduce cancels as well, then programmers need to think about
> writing cancel-safe code.  If stack unwinding for thread cancellation
> is allowed at calls to functions declared "throw ()", then I think it
> will harder for programmers to write code which is exception-safe and
> cancel-safe.
> 
> The C++ standard specifies many standard library functions as being
> "throw ()", and this provides an important guarantee which helps
> programmers that want to write exception-safe code.  If these functions
> might be interrupted by a thread cancellation, then I suspect that
> writing exception-safe and cancel-safe code will be very difficult.

>From a programmer point of view, I'd like to see functions defined as
throw() do one thing and one thing only when an exception is thrown,
and that is call unexpected(). Anything else is code bloat. Exceptions
might be a simple method for providing thread cancellation for the
compile writers, but it changes the expected behaviour and size of my
program.

Regards,

/Mike



More information about the Gcc-patches mailing list