This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: catch(...) and forced unwind


On Thu, 2003-12-18 at 05:38, Jamie Lokier wrote:
> Matt Austern wrote:
> > Note that it's possible to temporarily disable thread cancellation in
> > critical regions of code.  It might be appropriate for glibc and/or
> > libstdc++ to do that.  On the other hand, we'll have to think carefully
> > about standard conformance if we do something like that.
> 
> Why not make C++ "throw()" functions automatically disable thread
> cancellation when they are entered and restore the state when they exit?

That's a special case.

You'd also want to do the disabling inside "throw (int)" functions for
example.  And, then, you'd want to reenable if a "throw (int)" function
called a "throw (...)" function (perhaps inside a try-block).

I think that if you did all that, your idea would not violate either
standard.  However, it still wouldn't really solve the problem.  For
example:

  // This function has no exception-specification but I know
  // it only throws ints!
  inline void f() { printf ("Throwing now!"); throw 3; }

  // This function will never throw anything.
  void g() throw () { try { f(); } catch (int) { } }

is the sort of C++ code that could be validated in a non-threaded
environment, but would call "std::terminate" if "printf" were
cancelled.  (Unless other changes were made to C++ to special-case the
thread cancellation exception, which is the idea that I oppose.)

-- 
Mark Mitchell <mark@codesourcery.com>
CodeSourcery, LLC


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]