Re: handling exceptions

Laurent Guerby <>
29 Oct 1999 02:36:03 -0400

          From comp.compilers

Related articles
handling exceptions (Maikel Pennings) (1999-10-27)
Re: handling exceptions (1999-10-28)
Re: handling exceptions (Christian Stapfer) (1999-10-28)
Re: handling exceptions (1999-10-29)
Re: handling exceptions (Gautier) (1999-10-29)
Re: handling exceptions (Laurent Guerby) (1999-10-29)
Re: handling exceptions (Ehud Lamm) (1999-10-31)
| List of all articles for this month |

From: Laurent Guerby <>
Newsgroups: comp.compilers
Date: 29 Oct 1999 02:36:03 -0400
Organization: Club-Internet (France)
References: 99-10-127
Keywords: errors

Maikel Pennings <> writes:
> Does anyone know how a compiler (e.g. ada95 compiler) handles
> exceptions. I have to add exception handling to a compiler for a
> project, and I'm wondering how this is done in real compilers

Well you can always grab the latest source release of the GNAT, the
GNU Ada 95 compiler and look at the comments (the exception stuff is
heavily commented both in the front-end and in the run-time).


Right now, AFAIK, GNAT offers two mechanisms for handling exceptions,
one based on setjmp/longjmp, which is very portable but induces
run-time overhead when entering scopes with exception handlers, and a
new one, the so-called "zero-cost exception scheme", which has no
run-time overhead when entering scopes with exception handlers and use
code-tables to know what to do when an exception is raised, and
usually needs some platform specific code (it is nicely abstracted
though, see the code for the Ada.Exceptions package).

If you want to study high-level to low-level code transformation, GNAT
is very interesting since it has a flag (-gnatdg) that shows the
"low-level" Ada code when the front-end expander has done its job, so
you can see how "high-level" constructs are broken down into run-time
calls. (One of the latest gizmo with 3.12 is that you can set a flag
to be able to debug into the generated low-level Ada code instead of
the original programmer-written one ;-).

If you want more help, you can subscribe to the GNAT chat mailing-list
and ask questions there, GNAT knowledgeable people are looking there.

<> for subscription information.


Post a followup to this message

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