[Issue 15306] New: Delegates with shared context

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Nov 9 04:12:03 PST 2015


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

          Issue ID: 15306
           Summary: Delegates with shared context
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: jakobovrum at gmail.com

void main()
{
    int i = 42;

    // Correctly prevented for immutable context
    // auto dg = delegate void() immutable { auto inner = i; };

    // Incorrectly allowed; context has unshared aliasing
    int* p = &i;
    auto dg = delegate int() shared { return *p; };
    assert(dg() == i);
}

---

Also, there doesn't appear to be any inference of the context type qualifier,
neither for function literals nor nested functions. Taking the address of a
member function of an immutable/shared object doesn't seem to give the context
type qualifier either.

--


More information about the Digitalmars-d-bugs mailing list