digitalmars.D.bugs - [Issue 22519] New: [dip1000] cannot take address of `ref return`
- d-bugmail puremagic.com (28/30) Nov 18 2021 https://issues.dlang.org/show_bug.cgi?id=22519
https://issues.dlang.org/show_bug.cgi?id=22519 Issue ID: 22519 Summary: [dip1000] cannot take address of `ref return` Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: dkorpel live.nl Compile with -preview=dip1000 ``` safe: void main() { int x; int* a = &identity(x); // error int* b = identity(x).addressOf; // workaround } ref int identity(return ref int x) {return x;} int* addressOf(return ref int x) {return &x;} ```onlineapp.d(5): Error: cannot take address of `ref return` of `identity()` in ` safe` function `main`This is a needless limitation. As shown, it can be worked around using the `addressOf` function instead of the & operator. --
Nov 18 2021