Skip to content

isZeroInit is wrongly false for some struct/union nesting #5559

Open
@dlangBugzillaToGithub

Description

@dlangBugzillaToGithub

Nick Treleaven reported this on 2024-10-05T16:35:25Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=24797

Description

The fix for issue 24776 does not catch cases like this:

union U3
{
    int y;
    struct {
        float z, w; // z ignored, but w has a different offset to y
    }
}
static assert(__traits(isZeroInit, U3)); // fails

Using `StructDeclaration.members` rather than `fields` may be necessary as a fallback when there are overlapped fields - see:
https://github.com/dlang/dmd/pull/16858#discussion_r1769869617

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions