www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16029] New: D exception aborts program when called from C++


          Issue ID: 16029
           Summary: D exception aborts program when called from C++
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: david.feurle sodgeit.de

I export a function from d to c++ with extern(C++). The d code has a try catch
statement on the highest level.Whenever the d code throws a exception the
program aborts. I have c++ objects on the call stack and call the function in
d. Then there is the d try catch statement and then the d exception throw. The
d code:

extern (C++) void ThrowEx() {
    try {
        throw new Exception("hello");
    } catch (Exception ex) {

The c++ code:

extern "C" int rt_init();
void ThrowEx();
void func() {
When I change ThrowEx to not throw an exception everything works as expected.
The d code gets executed and no error occurs.

When the program crashes the following output is generated:

dwarfeh(224) fatal error
uncaught exception

May 16 2016