This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Using EH from C
- From: "david daney" <ddaney at avtrex dot com>
- To: "Stelios Xanthakis" <sxanth at ceid dot upatras dot gr>,"Richard Henderson" <rth at redhat dot com>
- Cc: <gcc at gcc dot gnu dot org>
- Date: Sat, 1 May 2004 21:39:46 -0700
- Subject: RE: Using EH from C
On Sat, 1 May 2004, Richard Henderson wrote:
>> On Sat, May 01, 2004 at 05:09:23PM +0300, Stelios Xanthakis wrote:
>> > But of little use without another extension to create landing pads...:(
>>
>> Why in the world would you need that?
>Because if there's no landing pad, _Unwind_RaiseException
>ends up on abort()?
>
>I may be totally wrong, but what I'm trying to do is implement
>"stack unwind with cost-free cleanups from C".
>
>That's three things
>
>1. register destructors on EH
> Done: attribute(cleanup(function))
>
>2. call 'throw'
> Done: libgcc_eh and unwind.h
>
>3. set up a landing pad somewhere (try-catch).
> ???
>
>Where does _Unwind stop otherwise? main()?
>
>~S
gcc/testsuite/gcc.dg/cleanup9.c kind of does what you are talking about. I would setjump and set an attfibute(cleanup(function)) at the catch point, and then longjump from the cleanup function.
Why can't you use C++ for the try/catch part? Since all of this is GCC specific, if you have C and excpetions working it doesn't seem like using G++ would be a problem.
David Daney.