viirya commented on PR #2883: URL: https://github.com/apache/arrow-rs/pull/2883#issuecomment-1279885113
> Where is this called, I think I am being blind. It looks like this PR removes the alignment check in PrimitiveArray? Hmm? No, this PR doesn't remove it. Let me quote what I saw for now: ```rust pub fn values(&self) -> &[T::Native] { // Soundness // raw_values alignment & location is ensured by fn from(ArrayDataRef) // buffer bounds/offset is ensured by the ArrayData instance. unsafe { std::slice::from_raw_parts( self.raw_values.as_ptr().add(self.data.offset()), self.len(), ) } } ``` ```rust pub const unsafe fn from_raw_parts<'a, T>(data: *const T, len: usize) -> &'a [T] { // SAFETY: the caller must uphold the safety contract for `from_raw_parts`. unsafe { assert_unsafe_precondition!( is_aligned_and_not_null(data) && crate::mem::size_of::<T>().saturating_mul(len) <= isize::MAX as usize ); &*ptr::slice_from_raw_parts(data, len) } } ``` ```rust pub(crate) fn is_aligned_and_not_null<T>(ptr: *const T) -> bool { !ptr.is_null() && ptr.addr() % mem::align_of::<T>() == 0 } ``` BTW, I'm on a M1 Macbook so the toolchain is stable-aarch64-apple-darwin. Maybe you will see something different? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org