diff --git a/src/distributed_slice.rs b/src/distributed_slice.rs index 91ef99b..0a19835 100644 --- a/src/distributed_slice.rs +++ b/src/distributed_slice.rs @@ -268,6 +268,12 @@ impl DistributedSlice<[T]> { // using the unsafe `private_new`. None => unsafe { hint::unreachable_unchecked() }, }; + + // On Windows, make sure we discard provenance information. + // Otherwise, the compiler has enough information to see we are going "out of bounds". + #[cfg(target_os = "windows")] + let start = core::hint::black_box(start); + unsafe { slice::from_raw_parts(start, len) } } } diff --git a/tests/distributed_slice.rs b/tests/distributed_slice.rs index f8ab487..41ff5a0 100644 --- a/tests/distributed_slice.rs +++ b/tests/distributed_slice.rs @@ -69,4 +69,5 @@ fn test_elided_lifetime() { static ELEMENT: &str = "..."; assert!(!MYSLICE.is_empty()); + assert_eq!(MYSLICE[0], "..."); }