D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 22840 - [dip1000] inout method with inferred @safe escapes local data
Summary: [dip1000] inout method with inferred @safe escapes local data
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2022-03-03 10:35 UTC by Dennis
Modified: 2022-03-22 10:44 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Dennis 2022-03-03 10:35:13 UTC
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.
Comment 1 Dlang Bot 2022-03-22 08:42:59 UTC
@dkorpel updated dlang/dmd pull request #12689 "Fix issue 22027, 20149 - inout doesn't imply return" fixing this issue:

- Fix issue 22027, 22840 - inout doesn't imply return

https://github.com/dlang/dmd/pull/12689
Comment 2 Dlang Bot 2022-03-22 10:44:23 UTC
dlang/dmd pull request #12689 "Fix issue 22027, 20149 - inout doesn't imply return" was merged into master:

- 9082bb675362f06c7c50141ecebff960648546f1 by dkorpel:
  Fix issue 22027, 22840 - inout doesn't imply return

https://github.com/dlang/dmd/pull/12689