This is the mail archive of the 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]
Other format: [Raw text]

Re: [basic-improvements] try/finally support for c/c++

On Wed, 6 Nov 2002, Aldy Hernandez wrote:

> > > + containing one or statements, and a @code{__finally} block contatining
> > > + one or more statements.  The @code{__finally} block will execute after
> > > + the @code{__try} block but before the code following the
> > > + @code{__try/__finally} construct, even if the @code{__try} block exits
> > > + the current function.
> > 
> > There should be a corresponding mention of longjmp to that in the formal
> > edits.
> I don't understand what you want here.  Could you elaborate please?

It must be made clear in the user docs that exiting via longjmp yields
undefined behavior, rather than the finally block executing before longjmp
goes to its destination.

> Joseph, how does this one look?

You still need to make the jumps that aren't permitted into constraint
violations (with corresponding testcases for the diagnostics) except for
longjmp and computed goto cases (undefined behavior at runtime).

I don't think it's yet been stated whether you may jump into the finally 
block from outside, or what happens after the execution of the finally 
block if you do.

> + If a try block was exited by @code{return}, then the function returns
> + after finishing the finally block (unless inside other try block).  If
> + a try block is exited normally, then execution continues after the end
> + of the finally block.  If a try block is exited through an exception
> + being thrown (or forced unwinding), then after finally block exits,
> + the exception is resumed or forced unwinding continues.

This paragraph fails to mention what happens if the try block is exited by 
a jump (goto, break or continue).

Whichever cases of computed goto are defined / undefined need to be

> + A @code{goto}, @code{break}, @code{return}, or @code{continue}
> + statement can be used to transfer control out of a try block but not
> + into one.  Also, a @code{longjmp} may not be used to transfer control
> + into a try or finally block.  If done, the behavior is undefined.

You need to include @code{switch} in the statements that aren't permitted 
to transfer control into a try block.  Wasn't it intended that longjmp 
can't jump out either?

(Note: I'm not examining the C++98 edits, there may be similar issues

Joseph S. Myers

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