www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17790] New: [scope] Escaping pointer possible through array

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

          Issue ID: 17790
           Summary: [scope] Escaping pointer possible through array of
                    aggregates
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mathias.lang sociomantic.com

Compile with -dip1000, the following compiles but shouldn't:

```
struct Foo { int* p; }

void main ()  safe
{
    int* ptr = bar().p;
    assert(ptr !is null);
}

Foo bar ()  safe
{
    int i;
    Foo[] arr = [ Foo(&i) ];
    return arr[0];
}
```

--
Aug 28 2017