[Issue 16037] New: Closure allocation despite scope variable for ternary operator / CondExp

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue May 17 13:50:10 PDT 2016


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

          Issue ID: 16037
           Summary: Closure allocation despite scope variable for ternary
                    operator / CondExp
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: mathias.lang at sociomantic.com
                CC: public at dicebot.lv

The following allocates memory and thus does not compile:

```
void testXXX () @nogc
{
    Object o;
    scope bool delegate (Object) alwaysFalse = (Object y) { return false; };
    scope c1 = o !is null ? (Object y) { return o is y; } : alwaysFalse;
}
```

```
alloc.d(1): Error: function alloc.testXXX is @nogc yet allocates closures with
the GC
alloc.d(5):        alloc.testXXX.__lambda2 closes over variable o at alloc.d(3)
```

--


More information about the Digitalmars-d-bugs mailing list