[basic-improvements] try/finally support for c/c++
Jason Merrill
jason@redhat.com
Wed Nov 6 12:14:00 GMT 2002
On Wed, 6 Nov 2002 10:56:30 -0800, Richard Henderson <rth@redhat.com> wrote:
> On Wed, Nov 06, 2002 at 09:03:45AM -0500, Jason Merrill wrote:
>> > You probably need to define __finally in terms of destructors
>> > in order for this to work out properly. E.g. a finally block
>> > is the destructor for an anonymous object of an anonymous type.
>> > Or something. Perhaps Jason or Mark could help here?
>>
>> The code in the finally block is run on exit from the try block, except
>> that exiting a try block with a corresponding finally block via longjmp or
>> computed goto has undefined behavior.
>
> Yes, clearly, but how to integrate this statement cleanly with
> the ISO document? That is why I think we need to piggyback on
> the existing destructor language.
The above is proposed wording. :)
For destructors, the C++ standard just says (in stmt.dcl)
Variables
with automatic storage duration declared in the block are destroyed on
exit from the block (_stmt.jump_).
I think trying to word it in terms of a destructor would be too
complicated; it's easier to express cleanups in terms of try/finally.
Jason
More information about the Gcc-patches
mailing list