[Issue 13848] overlapping initialization for r

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 4 11:38:59 UTC 2019


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

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

--- Comment #6 from RazvanN <razvan.nitu1305 at gmail.com> ---

"If there are anonymous unions in the struct, only the first member of the
anonymous union can be initialized with a struct literal, and all subsequent
non-overlapping fields are default initialized." [1]

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

The error is therefore correctly issued, however the error message can be
improved. Currently, "overlapping initialization for r" does not hint at all
how the issue can be fixed.

A better workaround would be to have the union as the last field of the struct
and then initialize it as S(p, a);


More information about the Digitalmars-d-bugs mailing list