Big struct/class and T.init

Steven Schveighoffer schveiguy at
Sun Feb 19 18:26:08 UTC 2023

On 2/19/23 1:11 PM, Guillaume Piolat wrote:
> If my understanding is correct, the mere fact of having a:
>      struct S
>      {
>          char[16384] array;
>      }
> And then using it anywhere, will necessarily lead to a S.init being 
> created and linked, leading to a binary size inflation of 16kb.
> This is not a super high concern, but can inform design decisions.
> Is this correct?


that's not the case for all-zero .init though. At least in 
`TypeInfo.initializer`, it's pointing to null with array size indicating 
the amount of zeroes to write.

Testing with, switching between `char` and `int` changes 
the ASM output to show whether it's stored or not.


More information about the Digitalmars-d-learn mailing list