[Issue 19917] unions should require that all members are `= void` initialised

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 4 17:35:23 UTC 2019


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

--- Comment #8 from Manu <turkeyman at gmail.com> ---
(In reply to Andrei Alexandrescu from comment #7)
> That's excessive. Pasting from
> https://issues.dlang.org/show_bug.cgi?id=19919:
> 
> 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.

I don't think it's simple, it's a weird magic rule that you wouldn't/couldn't
expect, and you can't know unless you already know.
Anyway, if it is the case, then the compiler needs to emit an error if an
initialisation is applied to any non-first member explaining that rule.

--


More information about the Digitalmars-d-bugs mailing list