digitalmars.D.bugs - Full closures - Variable needlessly allocated on heap
- Xinok (23/23) Nov 03 2007 Compiled using DMD 2.007 on Windows.
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.
Nov 03 2007








Xinok <xnknet gmail.com>