[Issue 19825] Memory corruption involving lazy variadic, stdio and json

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 27 15:13:04 UTC 2019


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

ag0aep6g <ag0aep6g at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |ag0aep6g at gmail.com

--- Comment #2 from ag0aep6g <ag0aep6g at gmail.com> ---
Reduced test case:

----
import std.stdio;

struct JSONValue
{
    TaggedUnion payload;
}

struct TaggedUnion
{
    size_t[2] m_data;
    int m_kind;

    JSONValue opIndex(size_t i)
    {
        return JSONValue();
    }
}

void yap(lazy JSONValue arg)
{
    writeln(arg);
}

struct Foo
{
    int a;
    string name;
}

Foo makeFoo()
{
    JSONValue root;
    yap(root.payload[0].payload[0].payload[0]);

    Foo foo;
    return foo;
}

void main()
{
    auto foo = makeFoo();
    writeln(foo.name); // Garbled output, then an exception
}
----

--


More information about the Digitalmars-d-bugs mailing list