[Issue 19175] @safe code can escape local array references

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 27 09:24:56 UTC 2018


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

ag0aep6g <ag0aep6g at gmail.com> changed:

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

--- Comment #7 from ag0aep6g <ag0aep6g at gmail.com> ---
(In reply to anonymous4 from comment #6)
> Same for pointers:
[...]

Resolving the templates shows that this is related to `pure`:

----
@safe:

struct A
{
    int* r;
    this(int* q) pure { r = q; }
}

int* escape(int* r) pure
{
    return A(r).r;
}

int* f()
{
    int x;
    return escape(&x);
}
----

--


More information about the Digitalmars-d-bugs mailing list