This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: EH in C (was: Re: (lack of) Thread-safe exceptions on AIX(gcc-2.95.1)
- To: gcc at gcc dot gnu dot org
- Subject: Re: EH in C (was: Re: (lack of) Thread-safe exceptions on AIX(gcc-2.95.1)
- From: Bill Tutt <rassilon at list dot org>
- Date: Tue, 1 Feb 2000 00:22:41 -0800 (PST)
> llewley wrote:
> This is what catch(...) { throw;} is for. It works just like finally.
No it doesn't.
__finally() always gets executed. The catch(...) block is only executed
when an exception is thrown.
In this example, the fprintf() always occurs. In your example if foo()
hadn't thrown the exception, the fclose() would never have gotten called.
__try
{
.....
}
__finally
{
fprintf("I'm inside of __finally.\n");
}
__finally's sole purpose in life is to give C code (not C++, C) the chance
to perform cleanup actions in the face of asynchrnous exceptions (divide
by zero, AV, etc), SEH generated synchronous exceptions, and C++ generated
synchrnous exceptions. SEH wouldn't need __finally if C supported
destructors, but C doesn't, and I don't think it should.
Bill