[Issue 19371] New: Taking address of ref return in @safe code: compile-time checks fail

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 7 00:09:56 UTC 2018


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 at puremagic.com
          Reporter: stanislav.blinov at 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
}
```

--


More information about the Digitalmars-d-bugs mailing list