On Sunday, 11 November 2012 at 10:09:17 UTC, Jonathan M Davis wrote:
It still prints "hello", even with full optimations turned on. So, it must be allocating a closure in spite of scope. So, it looks to me like scope is just completely ignored and does absolutely nothing at this point, unless I'm just
completely missing something here.

Try this:

---
import std.stdio;

void delegate() global;

void foo(scope void delegate() del)
{
     global = del;
}


void f()
{
     {
         char[5] bar = "hello";
         foo((){writeln(bar);});
     }
}

void smashStack() {
    uint[1000] dummy = 0xbadcab1e;
    asm { nop; }
}

void main()
{
     char[7] baz = "goodbye";
     f();
     smashStack();
     global();
}
---

David

Reply via email to