April 15, 2023 [Issue 23841] New: isZeroInit does not take into account unions | ||||
---|---|---|---|---|
| ||||
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. -- |
Copyright © 1999-2021 by the D Language Foundation