[Issue 15996] @safe allows escaping of ptrs to variables going out of scope

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jun 7 00:32:58 PDT 2016


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

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at digitalmars.com

--- Comment #3 from Walter Bright <bugzilla at digitalmars.com> ---
The attachment:
---------------------------

safe:

import std.stdio;

struct T { int y; }

auto foo() {
    auto t = T(12345);
    auto x = &t.y;
    return x;
}

unittest {
    auto x = foo();
    writeln("Hello world");
    assert(*x == 12345);
}

--


More information about the Digitalmars-d-bugs mailing list