Bug 21192 – std.traits: Add trait for determining if a type has padding/alignment holes

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-08-23T22:08:23Z
Last change time
2024-12-01T16:37:32Z
Assigned to
No Owner
Creator
Iain Buclaw
Moved to GitHub: phobos#10436 →

Attachments

IDFilenameSummaryContent-TypeSize
1802identity.dexample implementationapplication/x-dsrc5737
1803identity.dexample implementation - no pragma(msg)application/x-dsrc5777

Comments

Comment #0 by ibuclaw — 2020-08-23T22:08:23Z
Created attachment 1802 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.
Comment #1 by ibuclaw — 2020-08-23T22:14:39Z
Created attachment 1803 example implementation - no pragma(msg)
Comment #2 by ibuclaw — 2020-08-24T07:02:11Z
(In reply to Iain Buclaw from comment #1) > Created attachment 1803 [details] > example implementation - no pragma(msg) Example implementation is missing creal and ireal support - should be added to the same condition as is(T == real).
Comment #3 by robert.schadek — 2024-12-01T16:37:32Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10436 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB