Proposal: Change @alignOf
of bit-packed types to either return null
or be an error
#7227
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Sibling-proposal, depends-on-but-half-in-conflict-with #7221 (read that one for context) .
Currently
@alignOf
returns a special value0
for bit-packed types. The argument has been made that the definition of alignment requirements as a power of two is more consistent both semantically and for hardware, however this prohibits the special value0
.Code dealing with byte alignment is (I think?) already not intended to be used with bit-packed types, so this may lead to mathematical errors in unsuspecting formulae. Instead, I think it's worthwhile to force a manual distinction, by either
@alignOf
return an optional type.To not clutter code with
.?
(which isn't very intrusive in the first place imho) users can just use@alignOf
indirectly via a helper function.@alignOf
of bit-packed types a compile error (which would complicate comptime/reflection code using it though - you'd be forced to reimplement and perform the validity check in userspace).The text was updated successfully, but these errors were encountered: