[Issue 1760] New: Closures - Variable unnecessarily allocated	on heap
    Frits van Bommel 
    fvbommel at REMwOVExCAPSs.nl
       
    Wed Jan  2 06:37:00 PST 2008
    
    
  
Lars Ivar Igesund wrote:
> d-bugmail at puremagic.com wrote:
> 
>> is means that 'int b' is allocated on the heap, even though the function
>> 'int getb()' is never referenced.
> 
> As Matti says, sort of a limitation, but not really one it is possible to
> solve because the compiler can never know if an object referencing it is
> linked in later on.
I disagree. In the example, no delegate pointing to three.getb() is ever 
created inside three(), and no other code can get to the symbol since it 
isn't in scope anywhere else. So the compiler could tell getb() doesn't 
even need to be emitted and 'b' can be stack-allocated, if only it would 
try to determine that fact.
    
    
More information about the Digitalmars-d-bugs
mailing list