Bug 22840 – [dip1000] inout method with inferred @safe escapes local data
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-03-03T10:35:13Z
Last change time
2022-03-22T10:44:23Z
Keywords
pull
Assigned to
No Owner
Creator
Dennis
Comments
Comment #0 by dkorpel — 2022-03-03T10:35:13Z
issue 20149 was closed with a partial fix. The fix doesn't work when `@safe` is inferred, example:
```
struct S
{
int buf;
auto slice() inout
{
return &buf;
}
}
int* fun() @safe
{
S sb;
return sb.slice(); // should error
}
```
Remove `inout` or add explicit `@safe` to `slice` and it correctly raises an error.