Bug 1876 – inside a non-static class method, should "&( f)" be same as "&(this.f)" ?

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2008-02-27T19:00:00Z
Last change time
2015-06-09T01:14:35Z
Assigned to
bugzilla
Creator
someanon

Attachments

IDFilenameSummaryContent-TypeSize
230fun.dfun/dlg ptr bugtext/plain839

Comments

Comment #0 by someanon — 2008-02-27T19:00:10Z
inside a non-static class method, should "&( f)" be same as "&(this.f)" ? $ cat fun.d ========================= import std.stdio; class A { public: int delegate(int, int) dgs[4]; int function(int, int) fps[4]; int f(int x, int y) { writefln("here"); int res = x + y; writefln(res); return res; } void bug_1() { fps[] = [&( f), &( f), &( f), &( f)]; // bug 1: this line shouldn't compile, but it passes the compiler and when run seg-faults! this.fps[0](1, 2); // seg-faults here! } void bug_2() { dgs[] = [&( f), &( f), &( f), &( f)]; // bug 1: why this line can't compile? // Error: e2ir: cannot cast from int function(int, int) to const(int delegate(int, int)) // in this context isn't "&( f)" same as "&(this.f)" ? dgs[] = [&(this.f), &(this.f), &(this.f), &(this.f)]; this.dgs[0](1, 2); } } int main() { A a = new A(); a.bug_1(); a.bug_2(); return 0; } =========================
Comment #1 by someanon — 2008-02-27T19:03:47Z
Created attachment 230 fun/dlg ptr bug
Comment #2 by bugzilla — 2008-03-07T00:36:44Z
Fixed dmd 2.012