https://issues.dlang.org/show_bug.cgi?id=23682
Issue ID: 23682 Summary: dip1000 problem with return by ref Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: bugzi...@digitalmars.com For: --- alias VErr = char*; @safe: ref char* front_p(return scope char** p) { return *p; } __gshared char* g; void main() { char* _errors; g = front_p(&_errors); // Error: address of variable `_errors` assigned to `g` with longer lifetime } --- The error is incorrect. The return value is indirected before assignment to `g`, so the address of `_errors` isn't being assigned to `g`, what `_errors` is pointing to is assigned to `g`. This can be seen by commenting out `@safe:`, compiling it, and looking at the assembler. --