[Issue 6245] New: Using an exception object inside a delegate, causes a crash

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 3 19:08:00 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6245

           Summary: Using an exception object inside a delegate, causes a
                    crash
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: soywiz at gmail.com


--- Comment #0 from Carlos Ballesteros Velasco <soywiz at gmail.com> 2011-07-03 19:03:00 PDT ---
import std.stdio;

void callDelegate(void delegate() cb) {
    cb();
}

void writeEx(Throwable o) {
    writefln("%s", o);
}

void works1() {
    Throwable o2;
    try {
        throw(new Exception("This is an error"));
    } catch (Throwable o) {
        o2 = o;
        callDelegate({
            writefln("%s", o2);
        });
    }
}

void works2() {
    try {
        throw(new Exception("This is an error"));
    } catch (Throwable o) {
        writeEx(o);
    }
}

void do_not_work() {
    try {
        throw(new Exception("This is an error"));
    } catch (Throwable o) {
        callDelegate({
            writefln("%s", o);
        });
    }
}

int main(string[] args) {
    works1();
    works2();
    do_not_work();
    return 0;
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list