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++
- From: Michael Matz <matz at suse dot de>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>,Aldy Hernandez <aldyh at redhat dot com>,Richard Henderson <rth at redhat dot com>, <gcc-patches at gcc dot gnu dot org>,<jason at redhat dot com>
- Date: Wed, 6 Nov 2002 12:02:42 +0100 (CET)
- Subject: Re: [basic-improvements] try/finally support for c/c++
Hi,
On Wed, 6 Nov 2002, Jakub Jelinek wrote:
> If __try block was exited by return, then the function returns after
> finishing the __finally block (unless inside other __try block), if
> __try is exited normally, then execution continues after the end
> of the finally block,
This would be fairly weird semantic. If the finally is formulated as a
destructor of an anonymous object (like Richard suggested) then it should
be run after the __try block exits, in _whichever_ way it does so. This
also makes much more sense to me. I wouldn't like to have to write:
__try {
if (bla())
return;
}
__finally {
cleanup();
}
cleanup();
just because the __finally block isn't executed sometimes. It also makes
the rule quite easy. The finally is executed after the try block, no
matter what.
Ciao,
Michael.