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]

Re: EH in C (was: Re: (lack of) Thread-safe exceptions on AIX (gcc-2.95.1)


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

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