I am trying to compile C ++ code with CLANg ++ as front end and backend as LLVM. Version 3.0 There seems to be a problem with exception handling. Whenever a code throws an exception, the program simply ends with the message "Termination after throwing an exception."
Here is one example code that I tried with CLANg ++.
struct A {}; struct B : virtual A {}; struct C : virtual A {}; struct D : virtual A {}; struct E : private B, public C, private D {}; extern "C" void abort (); void fne (E *e) { throw e; } void check(E *e) { int caught; caught = 0; try { fne(e); } catch(A *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fne(e); } catch(B *p) { abort ();} catch(...) { caught = 1; } if (!caught) abort(); caught = 0; try { fne(e); } catch(C *p) { caught = 1; if (p != e) abort();} catch(...) { abort(); } if (!caught) abort(); caught = 0; try { fne(e); } catch(D *p) { abort ();} catch(...) { caught = 1; } if (!caught) abort(); return; } int main () { E e; check (&e); check ((E *)0); return 0; }
I am completely new to LLVM, so I donβt have much idea about it. Does it also have anything to do with generating the LLVM exception table? The above problem persists for any code. I compiled the above code on a Linux machine. In addition, I tried to put printf in every catch clause, but did not respond. It seems that when the exception was thrown, no matching catch was found for the exception, and this led to a call to the shutdown function
rahul source share