[Issue 1760] New: Closures - Variable unnecessarily allocated on heap
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 1 08:54:06 PST 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1760
Summary: Closures - Variable unnecessarily allocated on heap
Product: D
Version: 2.009
Platform: PC
OS/Version: Windows
Status: NEW
Severity: trivial
Priority: P3
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: xnknet at gmail.com
Using this sample code:
int delegate() three(){
int a = 35;
int b = 60;
int c = 75;
int geta(){ return a; }
int getb(){ return b; }
writeln(&a);
writeln(&b);
writeln(&c);
return &geta;
}
void main(){
three();
}
Prints:
892FF4
892FF8
12FF28
This means that 'int b' is allocated on the heap, even though the function 'int
getb()' is never referenced.
--
More information about the Digitalmars-d-bugs
mailing list