Allow @bitCast
to pass through lvalues
#21935
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Since
@bitCast
never changes memory layout, it should be possible for it to be an lvalue when its parameter is one. For example:Resulting in
x == 0xffff_ffff
The advantage of this over just using
@ptrCast
is that@bitCast
checks the parameter type and target type have equal size, as well as that they have defined memory layout (eg. no auto-layout structs).This change could also be applied to
@intFromEnum
and@enumFromInt
, which are effectively@bitCast
in disguise.The text was updated successfully, but these errors were encountered: