Bug 16365 – cannot allow calling function pointer from delegate in @safe code

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-08-08T10:04:00Z
Last change time
2016-10-01T11:48:32Z
Keywords
accepts-invalid, pull, safe
Assigned to
nobody
Creator
ag0aep6g
See also
https://issues.dlang.org/show_bug.cgi?id=11176

Comments

Comment #0 by ag0aep6g — 2016-08-08T10:04:40Z
---- 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.
Comment #2 by bugzilla — 2016-08-22T08:51:28Z
Comment #3 by github-bugzilla — 2016-08-25T20:17:51Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3eece2fe875d35db428229b1121eda13e85b3883 partial solution for Issue 16365 - cannot allow calling function pointer from delegate in @safe code https://github.com/dlang/dmd/commit/627e96b986c9d94feefa5145a077eb2f820a3bef Merge pull request #6072 from WalterBright/fix16365-1 partial solution for Issue 16365 - cannot allow calling function poin…
Comment #4 by bugzilla — 2016-08-25T22:43:00Z
Comment #5 by bugzilla — 2016-08-25T23:09:07Z
Comment #6 by github-bugzilla — 2016-08-26T14:00:11Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/497fdfbee1b376d049d0531da789dbc60860fe1f fix Issue 16365 - cannot allow calling function pointer from delegate in @safe code https://github.com/dlang/dmd/commit/fe0ab0df5cfe4aa9c1ec4ea140e5521767e28df5 Merge pull request #6085 from WalterBright/fix16365 fix Issue 16365 - cannot allow calling function pointer from delegate…
Comment #7 by github-bugzilla — 2016-10-01T11:48:32Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/3eece2fe875d35db428229b1121eda13e85b3883 partial solution for Issue 16365 - cannot allow calling function pointer from delegate in @safe code https://github.com/dlang/dmd/commit/627e96b986c9d94feefa5145a077eb2f820a3bef Merge pull request #6072 from WalterBright/fix16365-1 https://github.com/dlang/dmd/commit/497fdfbee1b376d049d0531da789dbc60860fe1f fix Issue 16365 - cannot allow calling function pointer from delegate in @safe code https://github.com/dlang/dmd/commit/fe0ab0df5cfe4aa9c1ec4ea140e5521767e28df5 Merge pull request #6085 from WalterBright/fix16365