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.
Comment #1 by dlang-bot — 2022-03-22T08:42:59Z
@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 by dlang-bot — 2022-03-22T10:44:23Z
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