This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [basic-improvements] try/finally support for c/c++
On Thu, Nov 07, 2002 at 12:45:08PM +1100, Fergus Henderson wrote:
> (3) programmers must take great care when using longjmp()
> or try/finally to ensure that the two are not used together in
> a way that will result in undefined behaviour. This requires
> global (or at least non-local) analysis of the program.
> The analysis must be redone whenever any code is added which
> uses try/finally or longjmp, or even just when code which
> might use those constructs is rearranged. Furthermore,
> there are no tools which will help in this analysis, no
> support for run-time checking of this property, and bugs
> caused in this way may only show up on some platforms,
> so on some platforms testing will never detect the bug.
> OUCH!
3, really. Though ideally we'd have the function longjmp_unwind,
which is mentioned in the IA-64 psABI as a function that runs cleanups
along the path to the setjmp target.
> Another issue is using goto to jump out of nested functions.
> This has similar properties to longjmp or throwing exceptions,
> i.e. it unwinds the stack. The relationship between that and
> __try/__finally needs to be documented.
Same problem, though I'm happy to deprecate it.
r~