Re: Exception Handling

"Nick Maclaren" <>
10 Aug 2002 01:58:12 -0400

          From comp.compilers

Related articles
Exception Handling (David Jobet) (2002-07-21)
Re: Exception Handling (VBDis) (2002-07-24)
Re: Exception Handling (Casse Hugues) (2002-07-24)
Re: Exception Handling (jacob navia) (2002-07-24)
Re: Exception Handling (David Jobet) (2002-07-25)
Re: Exception Handling (journeyman) (2002-08-04)
Re: Exception Handling (Nick Maclaren) (2002-08-10)
Re: Exception Handling (Marco van de Voort) (2002-08-10)
Re: Exception Handling (Maxim Reznik) (2002-08-10)
Re: Exception Handling (Fergus Henderson) (2002-08-14)
Exception Handling (Bernhard Tschirren) (1998-09-13)
Re: Exception Handling (1998-09-18)
Re: Exception Handling (1998-09-18)
[2 later articles]
| List of all articles for this month |

From: "Nick Maclaren" <>
Newsgroups: comp.compilers
Date: 10 Aug 2002 01:58:12 -0400
Organization: University of Cambridge, England
References: 02-07-075 02-07-110
Keywords: errors
Posted-Date: 10 Aug 2002 01:58:12 EDT

"Casse Hugues" <> writes:
|> I uses the POSIX C functions setjmp()/lonjmp() from <setjmp.h> for
|> emulating exceptions in my C programs. These functions stores the
|> registers in a memory and restore it when the jump is performed. This is
|> the faster way to implement it I know (in C).

Unfortunately, that only appears to work. The C standard states
explicitly that they will not work for real exception handling, though
you can get them to work for language-created exceptions. Effectively
that means that SYSTEM exceptions (e.g. SIGINT or even I/O errors)
need system-specific code and Assembler.

|> But you must think about memory management because these functions
|> handle only the register and do not know anything about memory. Usually,
|> fast exception handling requires either special memory structure, or
|> garbage collection.

And other things, such as any global mode you set in the library. You
can easily use an extra argument for such state (it is how many
systems did it in the past), but you must pass that down through all
functions, whether they use exceptions or not. There are
optimisations, but they are messy and tricky to get right.

Nick Maclaren,
University of Cambridge Computing Service,
New Museums Site, Pembroke Street, Cambridge CB2 3QH, England.
Tel.: +44 1223 334761 Fax: +44 1223 334679

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.