diff --git a/src/dimension/mod.rs b/src/dimension/mod.rs index 4731da1b5..441629d54 100644 --- a/src/dimension/mod.rs +++ b/src/dimension/mod.rs @@ -57,6 +57,10 @@ pub fn stride_offset(n: Ix, stride: Ix) -> isize /// possible offset along the preceding axes. (Axes of length ≤1 are ignored.) pub(crate) fn dim_stride_overlap(dim: &D, strides: &D) -> bool { + if dim.slice().contains(&0) { + return false; + } + let order = strides._fastest_varying_stride_order(); let mut sum_prev_offsets = 0; for &index in order.slice() { diff --git a/tests/array.rs b/tests/array.rs index 391f88b95..8b3da409b 100644 --- a/tests/array.rs +++ b/tests/array.rs @@ -2241,6 +2241,14 @@ fn test_view_from_shape_ptr() assert_eq!(view, aview2(&[[0, 0, 2], [3, 4, 6]])); } +#[test] +fn test_view_mut_from_shape_ptr_empty_zero_strides() +{ + let ptr = std::ptr::dangling_mut::(); + let view = unsafe { ArrayViewMut2::from_shape_ptr((2, 0).strides((0, 0)), ptr) }; + assert_eq!(view.shape(), &[2, 0]); +} + #[should_panic(expected = "Unsupported")] #[cfg(debug_assertions)] #[test]