Skip to content

Commit decd59b

Browse files
committed
[cppyy] Set LowLevelView itemsize to sizeof(T) for fixed multidim arrays
For fixed contiguous C arrays (e.g. float a[2][2]), the ndim > 1 path in CreateLowLevelViewT was unconditionally setting view.itemsize to sizeof(void*), which is correct for pointer-to-pointer arrays but does not work for fixed arrays. Fixes #21378
1 parent 517a231 commit decd59b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

bindings/pyroot/cppyy/CPyCppyy/src/LowLevelViews.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,9 @@ static inline CPyCppyy::LowLevelView* CreateLowLevelViewT(
10931093
llp->fConverter = llp->fElemCnv;
10941094
} else {
10951095
// multi-dim array; sub-views are projected by using more LLViews
1096-
view.len = nx * sizeof(void*);
1097-
view.itemsize = sizeof(void*);
1096+
const size_t elemsize = isfix ? sizeof(T) : sizeof(void*);
1097+
view.len = nx * elemsize;
1098+
view.itemsize = elemsize;
10981099
for (Py_ssize_t idim = 1; idim < view.ndim; ++idim)
10991100
view.shape[idim] = shape[idim];
11001101

0 commit comments

Comments
 (0)