← Back to index
|
Original Bugzilla link
Bug 6245 – Using an exception object inside a delegate, causes a crash
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-07-03T19:03:00Z
Last change time
2022-08-15T14:43:45Z
Assigned to
No Owner
Creator
Carlos Ballesteros Velasco
Comments
Comment #0
by soywiz — 2011-07-03T19:03:00Z
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; }
Comment #1
by lovelydear — 2012-04-24T12:07:35Z
Confirmed with 2.059
Comment #2
by razvan.nitu1305 — 2022-08-15T14:43:45Z
I just compiled and ran the code with the latest master. It successfully compiles, runs and exits gracefully. It seems like this has been fixed.