----
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 */
}
----
Comment #1 by ag0aep6g — 2016-08-08T10:07:58Z
(In reply to ag0aep6g from comment #0)
> S s;
> void delegate(immutable int*, int*) @safe d = &s.f1;
> void function(immutable int*, int*) @safe f = d.funcptr; /* uh-oh */
Can also use `f = &S.f1;` to obtain the unsafe function pointer.