www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6245] New: Using an exception object inside a delegate, causes a crash

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: soywiz gmail.com



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: -------
Jul 03 2011
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6245


SomeDude <lovelydear mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear mailmetrash.com



PDT ---
Confirmed with 2.059

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