authorgravatar for 59504965+InKryption@users.noreply.github.comInKryption <59504965+InKryption@users.noreply.github.com> 2022-06-02 20:29:09+02:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-23 14:20:29+03:00
log9555b84ab43caeaaa85e7f25424c3ba731075142
tree296b7105069848470ce6a99a8c1ea480bec4635e
parent9734e643fb09526fa107e5a4912fbf6d77bcb6c3

langref: clarify permitted `@bitCast` usage.

The current phrasing is vague; it is unclear whether it is demonstrating an example of the type of permitted behavior, from which the rule set must be extrapolated, or it is stating that this restriction only applies to the relationship between integers and bare structs.

1 files changed, 1 insertions(+), 1 deletions(-)

doc/langref.html.in+1-1
...@@ -8005,7 +8005,7 @@ fn func(y: *i32) void {...@@ -8005,7 +8005,7 @@ fn func(y: *i32) void {
8005 <li>Convert {#syntax#}i32{#endsyntax#} to {#syntax#}u32{#endsyntax#} preserving twos complement</li>8005 <li>Convert {#syntax#}i32{#endsyntax#} to {#syntax#}u32{#endsyntax#} preserving twos complement</li>
8006 </ul>8006 </ul>
8007 <p>8007 <p>
8008 Works at compile-time if {#syntax#}value{#endsyntax#} is known at compile time. It's a compile error to bitcast a struct to a scalar type of the same size since structs have undefined layout. However if the struct is packed then it works.8008 Works at compile-time if {#syntax#}value{#endsyntax#} is known at compile time. It's a compile error to bitcast a value of undefined layout; this means that, besides the restriction from types which possess dedicated casting builtins (enums, pointers, error sets), bare structs, error unions, slices, optionals, and any other type without a well-defined memory layout, also cannot be used in this operation.
8009 </p>8009 </p>
8010 {#header_close#}8010 {#header_close#}
80118011