If a struct field is default-initialized to `void` then this will override any later default initialization of a whole instance of that struct. For example, in the following code: ////////////////////////////// struct Inner { uint alpha = void; uint beta = 66; } struct Outer { Inner inner = Inner(23, 99); } void main () { import std.stdio : writeln; Outer outer; outer.inner.writeln; } ////////////////////////////// ... the result with dmd is that `outer.inner` is `Inner(0, 99)` instead of the expected `Inner(23, 99)`. Compiling with e.g. LDC produces the expected result of `Inner(23, 99)`. Note, the issue still appears even if DMD is used with the same frontend version as LDC. This therefore appears to be a DMD backend issue.
Covered by DMD's PR https://github.com/dlang/dmd/pull/6427
This regression was introduced with https://github.com/dlang/dmd/pull/5392 and got released with 2.071.0.
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/5f490432785a36efea2cb4dcda0d3ebb036d6c21 Fix issue 17073 - Do not ignore the explicit initializers We don't really care about the _init being void-initialized when the user has supplied an explicit value for a given field of the aggregate. https://github.com/dlang/dmd/commit/ac7efd9fdff63645e6c9b0278a8307dd07e3bfc1 Merge pull request #6427 from LemonBoy/b17073 Fix issue 17073 - Do not ignore the explicit initializers merged-on-behalf-of: Martin Nowak <code@dawg.eu>
Thanks everyone! Much appreciated :-)
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/5f490432785a36efea2cb4dcda0d3ebb036d6c21 Fix issue 17073 - Do not ignore the explicit initializers https://github.com/dlang/dmd/commit/ac7efd9fdff63645e6c9b0278a8307dd07e3bfc1 Merge pull request #6427 from LemonBoy/b17073
Commits pushed to newCTFE at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/5f490432785a36efea2cb4dcda0d3ebb036d6c21 Fix issue 17073 - Do not ignore the explicit initializers https://github.com/dlang/dmd/commit/ac7efd9fdff63645e6c9b0278a8307dd07e3bfc1 Merge pull request #6427 from LemonBoy/b17073