digitalmars.D.bugs - [Issue 23841] New: isZeroInit does not take into account unions
- d-bugmail puremagic.com (25/25) Apr 15 2023 https://issues.dlang.org/show_bug.cgi?id=23841
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 puremagic.com Reporter: dkorpel 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. --
Apr 15 2023