```
union U
{
float x = 0;
float y;
}
static assert(__traits(isZeroInit, U)); // fails
```
It also wastes bytes in the binary because it emits `U.init` in .rodata instead of .bss.
Workaround: add `=void` to void initialize the other union members.
Comment #1 by dlang-bot — 2024-09-20T16:16:13Z
@ntrel updated dlang/dmd pull request #16858 "Fix Bugzilla 24776 - Struct with anonymous union has wrong isZeroInit" fixing this issue:
- Fix Bugzilla 23841 - isZeroInit does not take into account unions
https://github.com/dlang/dmd/pull/16858
Comment #2 by dlang-bot — 2024-10-05T00:56:49Z
dlang/dmd pull request #16858 "Fix: isZeroInit does not take into account unions" was merged into master:
- 261044eb866a952dab4063ea4aa945916bc444b1 by Nick Treleaven:
Fix Bugzilla 23841 - isZeroInit does not take into account unions
https://github.com/dlang/dmd/pull/16858