[LLVMdev] Getting exceptions to work?

Eli Friedman eli.friedman at gmail.com
Mon May 18 00:17:57 PDT 2009

On Sun, May 17, 2009 at 11:54 PM, Talin <viridia at gmail.com> wrote:
> I've been struggling for several days, trying to get native exceptions to
> work in my code. I managed to boil down the IR to the simplest possible
> example that I can think of.
> If anyone on this list can tell me what changes I need to make to the
> following code to get it to work (i.e. return 0 instead of a bus error), it
> would make my life immensely better.

It looks like you're missing some required code in main() to catch the
exception.  Try comparing with the output of "llvm-gcc -x c++ - -o -
-S -O2 -emit-llvm" for a simple program like the following:

__attribute__((noinline)) int a() { throw 1; } int main() { try { a();
} catch (...) { return 0; } return 1; }


More information about the llvm-dev mailing list