[Issue 17959] New: [DIP1000] Can store scope delegate in non-scope member

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 1 17:50:04 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=17959

          Issue ID: 17959
           Summary: [DIP1000] Can store scope delegate in non-scope member
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: mathias.lang at sociomantic.com

The following segfault:

```
class Foo
{
    private void delegate () @safe escape;
    void esc () @safe scope
    {
        this.escape = &this.esc;
    }
}

void main () @safe
{
    auto x2 = bar();
    assert(x2 !is null);
    x2();
}

void delegate() @safe bar () @safe
{
    scope o = new Foo;
    o.esc;
    return o.escape;
}
```

I'd except the assignment in esc to fail.
Tested with v2.076.1 and f3446967d

--


More information about the Digitalmars-d-bugs mailing list