[Issue 19919] Incorrect initialization of union when first member isn't marked = void

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 4 12:26:31 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19919

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
The spec:

"Unions are by default initialized to whatever the Initializer for the first
field is, and if none is supplied, to the default initializer for the first
field's type" [1]

It seems that the resolution to this would be to issue an error (that would
state that the initialization is not used) if we were to stick to the spec.

Or we could modify the spec and allow a single explicit initializer per union.

[1] https://dlang.org/spec/struct.html#default_union_init

--


More information about the Digitalmars-d-bugs mailing list