Two bugs found: GC bug as well as scope delegate bug

Mehrdad wfunction at hotmail.com
Sun Aug 7 18:17:13 PDT 2011


OK so apparently the GC was working fine, my bad.
I'm not sure about the compiler, though.

When I have this code:

     void foo(int a, scope void delegate(int) sink)
     {
         sink(a);
     }
     void main()
     {
         int tmp;
         foo(5, delegate(int c) { tmp = c; });
     }

I get a heap allocation as soon as main() is entered. It only happens 
because of the closure.
Why does this happen? Isn't the whole point of "scope" to prevent this?
(I didn't post this on the bug tracking system since I'm not sure if 
it's by design or not.)


More information about the Digitalmars-d mailing list