__attribute__((cleanup(function)) versus try/finally

Mike Stump mrs@apple.com
Thu May 8 18:30:00 GMT 2003


On Tuesday, May 6, 2003, at 12:54 PM, Jason Merrill wrote:
>>  o RTH (and others) are strongly in favor of try/finally, which is
>>  implemented by several others compilers.
>
> Myself among them.  try/finally is well defined, and already 
> implemented in
> other languages and other C compilers.  IMO the explicit syntax is in
> keeping with the spirit of C.  If we have any exception handling 
> support
> whatsoever in C, it should be try/finally.  And we've (for some 
> definition
> of we) always intended to have some EH in C someday.  Now that we're 
> trying
> to integrate pthreads with EH, it's time.

try/finally I think is a reasonable approach.

If table size is a big issue, we can have C default to sjlj EH (lower 
cost in non-EH code), and integrate in handling for sjlj exceptions 
into the dwarf EH system.  It might be possible to bracket the C code 
with a single dummy region that just grabs the top element of the sjlj 
EH stack and throws it, so that non-gcc unwinders can unwind and throw 
through and into the C code while still being ABI compatible.



More information about the Gcc mailing list