[Issue 23682] New: dip1000 problem with return by ref
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 9 02:10:18 UTC 2023
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: nobody at puremagic.com
Reporter: bugzilla at 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.
--
More information about the Digitalmars-d-bugs
mailing list