[Issue 17423] New: @safe code seg faults
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue May 23 16:25:59 PDT 2017
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 at puremagic.com
Reporter: eyal at 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 ?
--
More information about the Digitalmars-d-bugs
mailing list