[Issue 22366] New: [dip1000] scope variable can be assigned to associative array
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 8 14:44:57 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=22366
Issue ID: 22366
Summary: [dip1000] scope variable can be assigned to
associative array
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dkorpel at live.nl
Putting a scope variable in an associative array literal gives "scope variable
`x` may not be copied into allocated memory". However, you can still assign it:
```
int* fun(scope int* x)
{
int*[int] aa;
aa[0] = x; // should give an error
return aa[0];
}
void main()
{
int x;
assert(fun(&x) != &x); // fails, demonstrating &x was escaped
}
```
--
More information about the Digitalmars-d-bugs
mailing list