https://issues.dlang.org/show_bug.cgi?id=18814
--- Comment #3 from Jack Stouffer <[email protected]> --- (In reply to Marco Leise from comment #2) > First thing that came to my mind ... there is suddenly an obvious GC bug > exposed by writeln?! Probably more likely some custom stuff that overwrites > internal data structures or something, let's look at the provided test > case... > > GC.malloc(GC.BlkAttr.NO_SCAN); > > That does not look like the correct first argument to: > https://dlang.org/phobos/core_memory.html#.GC.malloc > > Could you please give the amount of bytes you want to allocate and then post > the corrected test case? ;) ========== import std.traits; import std.stdio; struct String { ref opOpAssign(string op, R)(R r) { convertToBig(); large.ptr[large.len .. r.length] = r; } ubyte isBig() { return small.slen; } void convertToBig() { import core.memory; char* p = cast(char*) GC.malloc(10, GC.BlkAttr.NO_SCAN); large.ptr = p; } struct Small { ubyte slen; } struct Large { size_t len; char* ptr; } Small small; Large large; } unittest { auto a = String(); a ~= " test test test test test"; writeln(a); } ========== --
