On Monday, 9 April 2018 at 11:15:14 UTC, Stefan Koch wrote:
On Monday, 9 April 2018 at 11:06:50 UTC, Shachar Shemesh wrote:
[ ... ]
During the s initialization, the entire "S" area is initialized, including the member arr which we asked to be = void.

Is this a bug?

Shachar

[ ... ] {This could be fixed, but may break code} [ ... ]

So currently on initalizsation we do this:
---
structPtr = cast(StructType*) alloc(structSize);
memcpy(structPtr, StructType.static_struct_initializer, StructType.sizeof);
----
which we could change to
---
structPtr = cast(StructType*) alloc(structSize);
foreach(initializerSegment;StructType.InitializerSegments)
{
memcpy((cast(void*)structPtr) + initializerSegment.segmentOffset,
           (cast(void*) initializerSegment.segmentPtr),
           initializerSegment.segmentSize);
}
---

This will potentially remove quite a lot of binary bloat since void-members do no longer need to be stored in initializers, and initialization overhead. In terms of implementation this _should_ be straight-forward but well ... runtime and compiler interaction can be a mess.

Reply via email to