www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19371] New: Taking address of ref return in safe code:

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

          Issue ID: 19371
           Summary: Taking address of ref return in  safe code:
                    compile-time checks fail
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: stanislav.blinov gmail.com

Static asserts in the snippet below shouldn't trigger:

```
void main()  safe {
    int x;
    ref int get() { return x; }

    static assert(!is(typeof(&get())));
    static assert(!is(typeof(()  safe { return &get(); })));
    static assert(!__traits(compiles, { auto p = &get(); }));

    //auto p = &get(); // cannot take address of ref return in  safe
}
```

--
Nov 06 2018