This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: EH in C (was: Re: (lack of) Thread-safe exceptions on AIX (gcc-2.95.1)
- To: Bill Tutt <rassilon at list dot org>
- Subject: Re: EH in C (was: Re: (lack of) Thread-safe exceptions on AIX (gcc-2.95.1)
- From: Zack Weinberg <zack at wolery dot cumb dot org>
- Date: Tue, 1 Feb 2000 11:32:09 -0800
- Cc: Richard Henderson <rth at cygnus dot com>, llewelly at 198 dot dsl dot xmission dot com, gcc at gcc dot gnu dot org
- References: <20000201012540.A1039@cygnus.com> <Pine.LNX.3.95.1000201015824.25319A-100000@lima.mudlib.org>
On Tue, Feb 01, 2000 at 02:05:59AM -0800, Bill Tutt wrote:
>
> The annoying thing is that C based try/catch handlers need some kind of
> information about the exception that occurred if they want to do any
> useful processing. So if the C based try/catch handlers can't catch
> asynchrnous exceptions (segv, divdie by zero, etc) and information about
> C++ based exceptions is kind of useless is there any reason we need
> try/catch for C at all? i.e. can we get away with just a try/finally pair?
> This avoids the GetExceptionCode() problem altogether, but leaves
> AbnormalTermination(), but that seems like a fairly simple gcc builtin to
> code up.
The usual reason people want exceptions in C is to make pthread
cancellation play nice with C++. The pthread library has 'cleanups'
that happen when a thread is cancelled, that are basically
try/finally, but they don't interoperate with the C++ exception
mechanism. What you'd like is for pthread_cleanup_push/pop to be
implemented in terms of try/catch, and pthread_cancel to throw an
exception in the cancelled thread.
That requires only try { } catch (...) { }, plus some way to throw
an object (not just rethrow), in C.
zw