[Issue 16652] [Reg 2.071] returned rvalue destroyed too early

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 14 06:57:57 UTC 2018


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

--- Comment #2 from Walter Bright <bugzilla at digitalmars.com> ---
A further reduction:

struct Vector {
    this(ubyte a) {
        pragma(inline, false);
        buf = a;
    }

    ~this() {
        pragma(inline, false);
        buf = 0;
    }

    ubyte buf;
}

void bar(ubyte* v) {
    pragma(inline, true);
    assert(*v == 1);
}

void main() {
    bar(&Vector(1).buf);
}

It's the inlining of bar() that elicits the bug.

--


More information about the Digitalmars-d-bugs mailing list