Make @bitCast use @bitSizeOf instead of @sizeOf #8102
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Currently, the bitCast builtin function works such that it "Asserts that
@sizeOf(@TypeOf(value)) == @sizeOf(DestType)
." I'm proposing that this is changed to be bitSizeOf to exclude padding bytes.Why?
The main place I've found this interferes with programming is bit-casting to an integer which is a non-power of two in size. For example,
would not work because u24 is 4 bytes wide according to sizeOf, while Foo is 3 bytes wide, as is expected. Using bitSizeOf, this would compile, since both are 24 bits wide.
The text was updated successfully, but these errors were encountered: