[Issue 22840] New: [dip1000] inout method with inferred @safe escapes local data

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 3 10:35:13 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22840

          Issue ID: 22840
           Summary: [dip1000] inout method with inferred @safe escapes
                    local data
           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

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.

--


More information about the Digitalmars-d-bugs mailing list