Skip to content

Commit a910d9f

Browse files
committed
Clarify union transmute in the RFC example
1 parent e7dabd3 commit a910d9f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

text/0000-simd-ffi.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,12 @@ extern "C" fn foo(x: __m256) -> __m256;
131131

132132
fn main() {
133133
unsafe {
134-
union U { v: __m256, a: [u64; 4] }
134+
#[repr(C)] union U { v: __m256, a: [u64; 4] }
135135
if is_x86_feature_detected!("avx") {
136-
foo(U { a: [0; 4] }.v);
136+
// note: this operation is used here for readability
137+
// but its behavior is currently unspecified (see note above).
138+
let vec = U { a: [0; 4] }.v;
139+
foo(vec);
137140
}
138141
}
139142
}
@@ -212,5 +215,5 @@ target features are enabled at compile-time.
212215

213216
* Should it be possible to use, e.g., `__m128` on C FFI when the `avx` feature
214217
is enabled? Does that change the calling convention and make doing so unsafe ?
215-
We could extern this RFC to also require that to use certain types certain
218+
We could extend this RFC to also require that to use certain types certain
216219
features must be disabled.

0 commit comments

Comments
 (0)