You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// This function is necessary since `repr(simd)` has padding for non-power-of-2 vectors (at the time of writing).
/// With padding, `read_unaligned` will read past the end of an array of N elements.
///
/// # Safety
/// Reading `ptr` must be safe, as if by `<*const [T; N]>::read_unaligned`.
In particular, the last part says that there are no alignment restrictions on the pointer. However, the implementation performs a copy_nonoverlapping at type [T; N], which means that ptr actually must be T-aligned. This is unsound under the stated precondition for this function. (There don't seem to be tests actually using this with unaligned pointers, so Miri can't catch this.)
It is unclear to me what the intended behavior is, though I would have expected that alignment is indeed required -- i.e., I would guess the docs are wrong and the code is right.
The text was updated successfully, but these errors were encountered:
The
load
function is documented as follows:portable-simd/crates/core_simd/src/vector.rs
Lines 191 to 197 in 8d9bcda
In particular, the last part says that there are no alignment restrictions on the pointer. However, the implementation performs a
copy_nonoverlapping
at type[T; N]
, which means thatptr
actually must beT
-aligned. This is unsound under the stated precondition for this function. (There don't seem to be tests actually using this with unaligned pointers, so Miri can't catch this.)It is unclear to me what the intended behavior is, though I would have expected that alignment is indeed required -- i.e., I would guess the docs are wrong and the code is right.
The text was updated successfully, but these errors were encountered: