From 771cea3690b52d11a6d5bc22a6627d683ce33814 Mon Sep 17 00:00:00 2001 From: Dillon Date: Tue, 6 Oct 2026 22:41:38 -0700 Subject: [PATCH] Set the stride of new dimensions from `convert_dims` If we add a new dimension, leaving the stride to the default might be `unresolved`. The stride really shouldn't matter for extent 1 dimensions, but strides are used in pointer arithmetic, and that pointer arithmetic can cause sanitizer issues even though the resulting pointer is never used. --- include/array/array.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/array/array.h b/include/array/array.h index 9e06b24..a2239f7 100644 --- a/include/array/array.h +++ b/include/array/array.h @@ -965,7 +965,11 @@ NDARRAY_HOST_DEVICE auto convert_dim(const std::tuple& u) { template = sizeof...(Us)), int> = 0> NDARRAY_HOST_DEVICE auto convert_dim(const std::tuple& u) { // For dims beyond the rank of U, make a dimension of type T_I with extent 1. - return decltype(std::get(internal::declval()))(1); + auto d = decltype(std::get(internal::declval()))(1); + if (!internal::is_static(decltype(d)::Stride)) { + d.set_stride(0); + } + return d; } template