Thread overview
[Issue 19919] Incorrect initialization of union when first member isn't marked = void
Jun 04, 2019
RazvanN
Jun 26, 2019
Dlang Bot
Jul 02, 2019
Dlang Bot
Jul 10, 2019
Dlang Bot
Jul 30, 2021
Dlang Bot
June 04, 2019
https://issues.dlang.org/show_bug.cgi?id=19919

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

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

--- Comment #1 from RazvanN <razvan.nitu1305@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

--
June 04, 2019
https://issues.dlang.org/show_bug.cgi?id=19919

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
                 CC|                            |andrei@erdani.com

--- Comment #2 from Andrei Alexandrescu <andrei@erdani.com> ---
I think the principle of maximum simplicity goes like this:

* Only the first field can have an initializer (if you want another field...
move it to the top).
* If that initializer is "= void", the union is void-initialized.

All else is in error. That's that. Doesn't prevent any work getting done and is simple to spec and implement.

--
June 26, 2019
https://issues.dlang.org/show_bug.cgi?id=19919

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@RazvanN7 created dlang/dmd pull request #10092 "Fix Issues 19919 and 19917 - Incorrect initialization of union when first member isn't marked = void" fixing this issue:

- Fix Issues 19919 and 19917 - Incorrect initialization of union when first member isn't marked = void

https://github.com/dlang/dmd/pull/10092

--
July 02, 2019
https://issues.dlang.org/show_bug.cgi?id=19919

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@RazvanN7 created dlang/dmd pull request #10122 "Fix Issues 19919 and 19917 - Incorrect initialization of union when first member isn't marked = void" fixing this issue:

- Fix Issues 19919 and 19917 - Incorrect initialization of union when first member isn't marked = void

https://github.com/dlang/dmd/pull/10122

--
July 10, 2019
https://issues.dlang.org/show_bug.cgi?id=19919

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #10122 "Fix Issues 19919 and 19917 - Incorrect initialization of union when first member isn't marked = void" was merged into master:

- a6c0a59757d137829187801fc059e4198c18e67d by RazvanN7:
  Fix Issues 19919 and 19917 - Incorrect initialization of union when first
member isn't marked = void

- 523dfc1b1be6759ebca5139ec805946bcd29f7d0 by RazvanN7:
  Fix Issues 19919 and 19917 - Incorrect initialization of union when first
member isn't marked = void

https://github.com/dlang/dmd/pull/10122

--
July 30, 2021
https://issues.dlang.org/show_bug.cgi?id=19919

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #12899 "End deprecation period for incorrect initialization of union when first member isn't marked (Issues 19919 and 19917)" was merged into master:

- 5600f50c129c45d7867238a0488fc49f8aa167cd by Iain Buclaw:
  End deprecation period for incorrect initialization of union when first
member isn't marked (Issues 19919 and 19917)

https://github.com/dlang/dmd/pull/12899

--