May 23, 2017 [Issue 17423] New: @safe code seg faults | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17423 Issue ID: 17423 Summary: @safe code seg faults Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: eyal@weka.io @safe: unittest { struct OpApply { int delegate(int) @safe myDlg; int opApply(int delegate(int) @safe dlg) { myDlg = dlg; return 0; } } struct Foo { OpApply o; int i; this(int x) { o = OpApply(); foreach(_; o) { i = 0; } i = x; } int call(int delegate(int) @safe dlg) { dlg(0); return i; } } auto foo1 = Foo(1); auto foo2 = Foo(2); import std.stdio; writeln(foo2.call(foo1.o.myDlg)); } Crashes with a seg-fault. This is apparently due to abuse of opApply, letting the delegate escape its scope, being considered @safe ? -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply