This is the mail archive of the gcc-patches@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: [basic-improvements] try/finally support for c/c++ - more tests


On Thu, Nov 07, 2002 at 12:18:33PM -0800, Geoff Keating wrote:
> Mark Mitchell <mark@codesourcery.com> writes:
> 
> > We're trying to implement one particular piece of functionality required
> > by the POSIX threads interface; namely "pthread_cleanup_push" and friends.
> > (I know that any feature might get used more widely, but this is the
> > motivation, as I understand it.)  Furthermore, we're trying to make the
> > POSIX threads cleanups play nice with exception-handling.
> 
> Yes, this is right, but your example is not the case we really care
> about.  What we particularly want to make work is this C++ code:
> 
> struct A { ~A() { ... } };
> 
> {
>   A foo;
>   sigpause ();  // cancellation point, I hope
> }
> 
> Here, if 'sigpause' gets cancelled, we want A's destructor to not be
> run.  At present, cancellation is implemented using setjmp/longjmp,

Don't you mean, "to be run"?

> and so knows nothing about C++ destructors, and so this doesn't work.
> If we made C++ use setjmp/longjmp for destructors, that would be very
> expensive for all C++ code.  Instead, we want to make cancellation use
> the C++ exception mechanism, because that's already there and so
> wouldn't impose any extra overhead on C++ code.  The problem is that
> then we can't implement pthread_cleanup_push in C, because C can't
> interact with the exception mechanism.
> 
> -- 
> - Geoffrey Keating <geoffk@geoffk.org>
> 

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


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