This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [basic-improvements] try/finally support for c/c++ - more tests
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Geoff Keating <geoffk at geoffk dot org>
- Cc: Mark Mitchell <mark at codesourcery dot com>,Zack Weinberg <zack at codesourcery dot com>,Richard Henderson <rth at redhat dot com>,Jakub Jelinek <jakub at redhat dot com>, Aldy Hernandez <aldyh at redhat dot com>,"gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>,"jason at redhat dot com" <jason at redhat dot com>
- Date: Thu, 7 Nov 2002 15:25:01 -0500
- Subject: Re: [basic-improvements] try/finally support for c/c++ - more tests
- References: <Pine.LNX.4.33.0211071302550.20702-100000@wotan.suse.de> <19940000.1036685525@warlock.codesourcery.com> <jmlm45m8va.fsf@desire.geoffk.org>
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