On 7/2/20 10:51 AM, kinke wrote:
On Thursday, 2 July 2020 at 16:51:52 UTC, kinke wrote:
`= void` for members doesn't work and, I dare say, not work anytime
soon if ever.
I've quickly checked; `= void` for members has initialize-with-zeros
semantics too, so with LDC, it's equivalent to `= 0` but applicable to
user-defined types as well.
For DMD, `= void` for non-default-zero-initialized members can be used
for the same effect. If all members are effectively zero-initialized,
the init symbol isn't emitted, and the compiler initializes the whole
struct with zeros. With `= 0`, DMD still emits the init symbol into the
object file, but doesn't use it (at least not for stack allocations).
TLDR: Seems like initializing (all non-default-zero-initialized) members
with `= void` is the portable solution to elide the init symbols *and*
have the compiler initialize the whole struct with zeros, so a manual
memset isn't required.
Thank you! I just checked: Even 2.084 behaves the same. I will deal with
double.nan, etc. for structs where they matter.
Ali