[Issue 24797] New: isZeroInit is wrongly false for some struct/union nesting
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Oct 5 16:35:25 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24797
Issue ID: 24797
Summary: isZeroInit is wrongly false for some struct/union
nesting
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: minor
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: nick at geany.org
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
--
More information about the Digitalmars-d-bugs
mailing list