https://issues.dlang.org/show_bug.cgi?id=16365
Issue ID: 16365
Summary: cannot allow calling function pointer from delegate in
@safe code
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Keywords: accepts-invalid, safe
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
----
struct S
{
void f1(immutable int* x, int* y) @safe { *y = 13; }
}
void main() @safe
{
S s;
void delegate(immutable int*, int*) @safe d = &s.f1;
void function(immutable int*, int*) @safe f = d.funcptr; /* uh-oh */
immutable int* x = new int(42);
assert(*x == 42); /* passes */
f(x, new int);
assert(*x == 42); /* fails */
}
----
--