@@ -100,11 +100,26 @@ namespace pybind11
100100 }
101101 };
102102
103- }
103+ } // namespace detail
104104}
105105
106106namespace xt
107107{
108+ namespace detail {
109+
110+ template <std::size_t N>
111+ struct numpy_strides
112+ {
113+ npy_intp value[N];
114+ };
115+
116+ template <>
117+ struct numpy_strides <0 >
118+ {
119+ npy_intp* value = nullptr ;
120+ };
121+
122+ } // namespace detail
108123
109124 template <class T , std::size_t N, layout_type L>
110125 struct xiterable_inner_types <pytensor<T, N, L>>
@@ -433,8 +448,8 @@ namespace xt
433448 template <class T , std::size_t N, layout_type L>
434449 inline void pytensor<T, N, L>::init_tensor(const shape_type& shape, const strides_type& strides)
435450 {
436- npy_intp python_strides[N] ;
437- std::transform (strides.begin (), strides.end (), python_strides,
451+ detail::numpy_strides<N> python_strides;
452+ std::transform (strides.begin (), strides.end (), python_strides. value ,
438453 [](auto v) { return sizeof (T) * v; });
439454 int flags = NPY_ARRAY_ALIGNED;
440455 if (!std::is_const<T>::value)
@@ -445,7 +460,7 @@ namespace xt
445460
446461 auto tmp = pybind11::reinterpret_steal<pybind11::object>(
447462 PyArray_NewFromDescr (&PyArray_Type, (PyArray_Descr*) dtype.release ().ptr (), static_cast <int >(shape.size ()),
448- const_cast <npy_intp*>(shape.data ()), python_strides,
463+ const_cast <npy_intp*>(shape.data ()), python_strides. value ,
449464 nullptr , flags, nullptr ));
450465
451466 if (!tmp)
0 commit comments