Full closures - Variable needlessly allocated on heap
Xinok
xnknet at gmail.com
Sat Nov 3 05:35:17 PDT 2007
Compiled using DMD 2.007 on Windows.
int delegate() foo(){
int a = 30;
int b = 60;
int c = 90;
int one(){ return a; }
int two(){ return b; }
writefln(&a);
writefln(&b);
writefln(&c);
return &one;
}
version(Windows) void main(){
foo();
}
Prints:
8B2FF4
8B2FF8
12FF28
This means that variable 'b' is being allocated on the heap, even though nested function 'two' is never referenced.
More information about the Digitalmars-d-bugs
mailing list