Skip to content

Commit 9b2f967

Browse files
mborgerdingstefanseefeld
authored andcommitted
avoid undefined behavior:
calling `front()` on a possibly empty `std::vector` crashes systems that use debug checks. See github issue boostorg#526 boostorg#526
1 parent fe087f9 commit 9b2f967

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/numpy/ndarray.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ ndarray from_data_impl(void * data,
127127
(PyArray_NewFromDescr(&PyArray_Type,
128128
incref_dtype(dt),
129129
shape.size(),
130-
const_cast<Py_intptr_t*>(&shape.front()),
131-
const_cast<Py_intptr_t*>(&strides.front()),
130+
const_cast<Py_intptr_t*>(shape.data()),
131+
const_cast<Py_intptr_t*>(strides.data()),
132132
data,
133133
flags,
134134
NULL)));

0 commit comments

Comments
 (0)