This is the mail archive of the
mailing list for the GCC project.
Re: try/finally in GNU C
- From: Gabriel Dos Reis <gdr at cs dot tamu dot edu>
- To: Andrew Pinski <pinskia at physics dot uc dot edu>
- Cc: Joe Buck <Joe dot Buck at synopsys dot COM>, Aldy Hernandez <aldyh at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Thu, 15 Jun 2006 18:42:37 -0500 (CDT)
- Subject: Re: try/finally in GNU C
- References: <200606152332.k5FNWRgo005397@earth.phy.uc.edu>
On Thu, 15 Jun 2006, Andrew Pinski wrote:
| > On Thu, Jun 15, 2006 at 07:21:03PM -0400, Andrew Pinski wrote:
| > > > while looking into a recent mismatch between GCC-4.x and a C dialect
| > > > EH implemented as setjmp/longjmp, I recalled there was a talk about
| > > > extending GNU C with __try/__finally construct:
| > > >
| > > > http://gcc.gnu.org/ml/gcc-patches/2002-11/msg00239.html
| > > >
| > > > What happened to that project? Is it dead for good?
| > >
| > > Doesn't the cleanup attribute to a variable do close to the same thing?
| > > http://gcc.gnu.org/onlinedocs/gcc/Variable-Attributes.html
| > It's not a replacement, because a finally clause, like a C++ catch
that is my sentiment as well.
| > clause, has access to any automatic variable in scope. You can only
| > pass one argument to a cleanup function, so to port a program that
| > uses try/finally could require a major rewrite.
| Nested functions come in handy here really.
I welcome suggestions that do not require major rewrites.
The compiler already has dependencies on GNU C, so GNUism is not a
problem. However, simplicity of the work-arouond is premium.