www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22977] New: [dip1000] can escape scope pointer returned by

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

          Issue ID: 22977
           Summary: [dip1000] can escape scope pointer returned by nested
                    function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dkorpel live.nl

Nested function `fn` does not get `return` inferred here:
```
int* gPtr;

void main()  safe
{
    scope int* sPtr;
    int* fn() { return sPtr; }
    gPtr = fn();
}
```

--
Apr 03 2022