Bug 10324 – Wrong type for delegate.funcptr

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-10T13:30:00Z
Last change time
2015-06-09T05:15:01Z
Assigned to
nobody
Creator
simen.kjaras

Comments

Comment #0 by simen.kjaras — 2013-06-10T13:30:54Z
import std.stdio; auto foo() { int n = 4; return ()=>n; } void main( ) { auto dg = foo(); auto fn1 = dg.funcptr; auto fn2 = cast(int function(void*))fn1; fn2(dg.ptr); // 1 fn1(); // 2 } This program crashes with an access violation, because fn1 has the wrong type, and thus gets called with the wrong number of parameters. I'm not entirely sure what the correct type is, but I expect int function(void*), as it takes the context pointer as an additional parameter, and that is typed void*.
Comment #1 by yebblies — 2013-08-17T23:15:59Z
*** This issue has been marked as a duplicate of issue 2672 ***