I tried to create an empty array with the following command:
let shape = (1, 0).strides((0, 0));
let ptr = std::ptr::dangling::<f64>();
unsafe { ArrayView2::from_shape_ptr(shape, ptr) }
It fails with "The strides must not allow any element to be referenced by two different indices".
But the slightly different code works:
let shape = (0, 1).strides((0, 0));
let ptr = std::ptr::dangling::<f64>();
unsafe { ArrayView2::from_shape_ptr(shape, ptr) }
My expectation would be that both variants work fine.
I think the bug is inside dim_stride_overlap, which fails before the first 0 dimension is found and therefore recognises that the complete array is empty.
By the way, I use (0, 0) strides, since ndarray does the same for empty array e.g. created via zeros function.
I tried to create an empty array with the following command:
It fails with "The strides must not allow any element to be referenced by two different indices".
But the slightly different code works:
My expectation would be that both variants work fine.
I think the bug is inside
dim_stride_overlap, which fails before the first0dimension is found and therefore recognises that the complete array is empty.By the way, I use
(0, 0)strides, since ndarray does the same for empty array e.g. created viazerosfunction.