This is the mail archive of the gcc@gcc.gnu.org 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]

Re: EH in C (was: Re: (lack of) Thread-safe exceptions on AIX(gcc-2.95.1)



> 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



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