Bug 23079 – [dip1000] be more lenient when taking address of `ref` return

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-05-02T11:15:37Z
Last change time
2022-05-11T06:53:04Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2022-05-02T11:15:37Z
Came up in the newsgroup: https://forum.dlang.org/post/[email protected] > 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.
Comment #1 by dlang-bot — 2022-05-02T11:45:14Z
@dkorpel created dlang/dmd pull request #14062 "Fix issue 23079 - be more lenient when taking address of `ref` return" fixing this issue: - Fix issue 23079 - be more lenient when taking address of `ref` return https://github.com/dlang/dmd/pull/14062
Comment #2 by dlang-bot — 2022-05-11T06:53:04Z
dlang/dmd pull request #14062 "Fix issue 23079 - be more lenient when taking address of `ref` return" was merged into master: - 0c669a33f86d6c8e8066e79b77a7540bacaef9e3 by Dennis Korpel: Fix issue 23079 - be more lenient when taking address of `ref` return https://github.com/dlang/dmd/pull/14062