Bug 17073 – [Reg 2.071.0] Priority clash with `void` default initialization of struct fields

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-01-08T14:10:00Z
Last change time
2017-01-16T23:26:30Z
Assigned to
nobody
Creator
joseph.wakeling

Comments

Comment #0 by joseph.wakeling — 2017-01-08T14:10:13Z
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.
Comment #1 by bitter.taste — 2017-01-10T22:23:12Z
Comment #2 by code — 2017-01-13T12:48:19Z
This regression was introduced with https://github.com/dlang/dmd/pull/5392 and got released with 2.071.0.
Comment #3 by github-bugzilla — 2017-01-13T15:04:21Z
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 <[email protected]>
Comment #4 by joseph.wakeling — 2017-01-13T20:51:18Z
Thanks everyone! Much appreciated :-)
Comment #5 by github-bugzilla — 2017-01-15T01:21:05Z
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
Comment #6 by github-bugzilla — 2017-01-16T23:26:30Z
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