[Issue 23841] New: isZeroInit does not take into account unions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Apr 15 17:22:48 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=23841
Issue ID: 23841
Summary: isZeroInit does not take into account unions
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P4
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dkorpel at live.nl
```
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.
--
More information about the Digitalmars-d-bugs
mailing list