[Issue 19752] dip1000 isn't @safe if struct contains a slice

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 19 18:38:42 UTC 2019


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

ag0aep6g <ag0aep6g at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com

--- Comment #1 from ag0aep6g <ag0aep6g at gmail.com> ---
This seems to come down to `ref` parameters. `this` is a `ref` parameter,
right?

This works:

    struct Container1
    {
        int* ints;
    }
    Container1* range1(return scope Container1* that) @safe
    {
        return that; /* accepted */
    }

This doesn't:

    struct Container2
    {
        int* ints;
    }
    Container2* range2(return scope ref Container2 that) @safe
    {
        return &that; /* Error: cannot take address of scope parameter that */
    }

As far as I see, the two should be same to DIP 1000.

--


More information about the Digitalmars-d-bugs mailing list