digitalmars.D.bugs - [Issue 1876] New: inside a non-static class method, should "&( f)" be same as "&(this.f)" ?
- d-bugmail puremagic.com (50/50) Feb 27 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1876
- d-bugmail puremagic.com (6/6) Feb 27 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1876
- d-bugmail puremagic.com (9/9) Mar 06 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1876
http://d.puremagic.com/issues/show_bug.cgi?id=1876 Summary: inside a non-static class method, should "&( f)" be same as "&(this.f)" ? Product: D Version: 2.011 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: someanon yahoo.com 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; } ========================= --
Feb 27 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1876 Created an attachment (id=230) --> (http://d.puremagic.com/issues/attachment.cgi?id=230&action=view) fun/dlg ptr bug --
Feb 27 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1876 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED Fixed dmd 2.012 --
Mar 06 2008