[c++-pthreads] Re: thread-safety definition

Alexander Terekhov boo at terekhov.de
Mon Jan 12 15:28:28 UTC 2004


Dave Butenhof wrote:
[...]
> While I didn't have anything specific in mind, just a general concern,
> one example that occurs to me is "catch(...) {...; throw;}". One must be
> careful about specifying the "cancelled" state of the thread here; it
> shouldn't be possible to consider the exception destroyed during the
> body of the catch prior to the re-throw. I don't know if the current
> wording in the standard would allow this interpretation: ....

That's 15.1/6 and 15.1/7 (no changes in TC1-2003 edition, AFAIK).

6 A throw-expression with no operand rethrows the exception being 
  handled. The exception is reactivated with the existing temporary; 
  no new temporary exception object is created. The exception is no 
  longer considered to be caught; therefore, the value of 
  uncaught_exception() will again be true. [Example: code that must 
  be executed because of an exception yet cannot completely handle 
  the exception can be written like this:

        try {
                // ...
        }               
        catch (...) {           // catch all exceptions
                                
                // respond (partially) to exception

                throw;          // pass the exception to some
                                // other handler
        }

  —end example]

7 The exception thrown is the one most recently caught and not 
  finished. An exception is considered caught when initialization 
  is complete for the formal parameter of the corresponding catch 
  clause, or when terminate() or unexpected() is entered due to a 
  throw. An exception is considered finished when the corresponding 
  catch clause exits or when unexpected() exits after being entered 
  due to a throw.

regards,
alexander.



More information about the c++-pthreads mailing list