www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23079] New: [dip1000] be more lenient when taking address of

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 puremagic.com
          Reporter: dkorpel 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. --
May 02 2022