[Issue 17790] New: [scope] Escaping pointer possible through array of aggregates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Aug 28 03:02:39 PDT 2017


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 at puremagic.com
          Reporter: mathias.lang at 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];
}
```

--


More information about the Digitalmars-d-bugs mailing list