[Issue 21192] New: std.traits: Add trait for determining if a type has padding/alignment holes
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 23 22:08:23 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21192
Issue ID: 21192
Summary: std.traits: Add trait for determining if a type has
padding/alignment holes
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: ibuclaw at gdcproject.org
Created attachment 1802
--> https://issues.dlang.org/attachment.cgi?id=1802&action=edit
example implementation
Such a trait could be used by core.internal.convert.toUbyte() to determine
whether it is safe to return all bits of a struct to compute the hash, or does
it need to selectively copy all fields.
Rationale: structs that are passed around in registers typically discard any
memset() operation done to zero all alignment holes, so comparing all bits for
equality may not work.
Attached example implementation.
--
More information about the Digitalmars-d-bugs
mailing list