https://issues.dlang.org/show_bug.cgi?id=21097
--- Comment #2 from [email protected] --- Two potential solutions: ``` // Avoid stack allocation, at the cost of virtual call to get the init symbol. { auto arr = cast(ubyte[])typeid(T).initializer(); if (arr.ptr is null) { (cast(ubyte*)val)[0 .. T.sizeof] = ubyte(0); } else { // Use fill to duplicate 'arr' to work around https://issues.dlang.org/show_bug.cgi?id=16394 (cast(ubyte*)val)[0 .. T.sizeof].fillbytes(arr); } } // Avoid stack allocation, at the cost of duplicating the init symbol (binary size increase) { import core.stdc.string : memcpy; shared static immutable T init = T.init; memcpy(&chunk, &init, T.sizeof); } ``` (one cannot access the init symbol directly) --
