[Issue 1876] New: inside a non-static class method, should "&( f)" be same as "&(this.f)" ?
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 27 17:00:11 PST 2008
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 at digitalmars.com
ReportedBy: someanon at 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;
}
=========================
--
More information about the Digitalmars-d-bugs
mailing list