[Issue 23079] New: [dip1000] be more lenient when taking address of `ref` return

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 2 11:15:37 UTC 2022


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

          Issue ID: 23079
           Summary: [dip1000] be more lenient when taking address of `ref`
                    return
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: safe
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dkorpel at live.nl

Came up in the newsgroup:
https://forum.dlang.org/post/srwgaecsoztshbtixgwf@forum.dlang.org

> Looks like the compiler has a blanket rule against taking the address 
> of a ref return value if the value's type contains indirections.

```
int** p;

ref int* get() @safe
{
    return *p;
}

int** g1() @safe
{
    return &get(); // error
}
```

DMD could figure out get() does not return a scope pointer and allow taking the
address of its return value.

--


More information about the Digitalmars-d-bugs mailing list