Issue 24776 - Struct with anonymous union has wrong isZeroInit
Summary: Struct with anonymous union has wrong isZeroInit
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2024-09-20 16:08 UTC by Nick Treleaven
Modified: 2024-10-05 16:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nick Treleaven 2024-09-20 16:08:54 UTC
struct S6 {
    union {
        int i1;
        float f1;
    }
}
static assert(__traits(isZeroInit, S6)); // fails

S6.init should be zero - `{ S6.i1.init }` according to:
https://dlang.org/spec/property.html#init

PR incoming.
Comment 1 Dlang Bot 2024-09-20 16:13:12 UTC
@ntrel created dlang/dmd pull request #16858 "Fix Bugzilla 24776 - Struct with anonymous union has wrong isZeroInit" fixing this issue:

- Fix Bugzilla 24776 - Struct with anonymous union has wrong isZeroInit

https://github.com/dlang/dmd/pull/16858
Comment 2 Dlang Bot 2024-10-05 00:56:50 UTC
dlang/dmd pull request #16858 "Fix: isZeroInit does not take into account unions" was merged into master:

- cbb7cb6f3cd2eeed05aca8a2853c17e8829d0d2c by Nick Treleaven:
  Bugzilla 24776 - Struct with anonymous union has wrong isZeroInit

- 179da5d3266fed3e9b3cbd65bf377d4149b31529 by Nick Treleaven:
  Fix Bugzilla 24776 - Struct with anonymous union has wrong isZeroInit

https://github.com/dlang/dmd/pull/16858