@@ -263,7 +263,8 @@ namespace ReSolve
263263 // NOTE: this is not one-indexed like the original is
264264 std::unique_ptr<index_type[]> pt = std::unique_ptr<index_type[]>(new index_type[m_]);
265265 for (index_type i = 0 ; i < m_; i++) {
266- pt[p_[i] - 1 ] = i;
266+ size_t j = static_cast <size_t >(p_[i] - 1 );
267+ pt[j] = i;
267268 }
268269
269270 // preprocessing since columns are stored unordered within lusol's workspace
@@ -274,7 +275,8 @@ namespace ReSolve
274275 for (index_type i = 0 ; i < initial_m; i++) {
275276 index_type column_nnz = lenc_[i];
276277 index_type column_nnz_end = offset - column_nnz;
277- index_type corresponding_column = pt[indr_[column_nnz_end + 1 ] - 1 ];
278+ size_t j = static_cast <size_t >(indr_[column_nnz_end + 1 ] - 1 );
279+ index_type corresponding_column = pt[j];
278280
279281 columns[corresponding_column + 1 ] = column_nnz;
280282 offset = column_nnz_end;
@@ -297,12 +299,14 @@ namespace ReSolve
297299
298300 offset = lena_ - 1 ;
299301 for (index_type i = 0 ; i < initial_m; i++) {
300- index_type corresponding_column = pt[indr_[offset - lenc_[i] + 1 ] - 1 ];
302+ size_t j = static_cast <size_t >(indr_[offset - lenc_[i] + 1 ] - 1 );
303+ index_type corresponding_column = pt[j];
301304
302305 for (index_type destination_offset = columns[corresponding_column];
303306 destination_offset < columns[corresponding_column + 1 ] - 1 ;
304307 destination_offset++) {
305- index_type row = pt[indc_[offset] - 1 ];
308+ size_t k = static_cast <size_t >(indc_[offset] - 1 );
309+ index_type row = pt[k];
306310
307311 // closest position to the target row
308312 index_type* closest_position =
@@ -365,7 +369,8 @@ namespace ReSolve
365369 // NOTE: this is not one-indexed like the original is
366370 std::unique_ptr<index_type[]> qt = std::unique_ptr<index_type[]>(new index_type[n_]);
367371 for (index_type i = 0 ; i < n_; i++) {
368- qt[q_[i] - 1 ] = i;
372+ size_t j = static_cast <size_t >(q_[i] - 1 );
373+ qt[j] = i;
369374 }
370375
371376 // preprocessing since rows technically aren't ordered either
@@ -386,7 +391,8 @@ namespace ReSolve
386391 index_type offset = locr_[p_[row] - 1 ] - 1 ;
387392
388393 for (index_type destination_offset = rows[row]; destination_offset < rows[row + 1 ]; destination_offset++) {
389- index_type column = qt[indr_[offset] - 1 ];
394+ size_t j = static_cast <size_t >(indr_[offset] - 1 );
395+ index_type column = qt[j];
390396
391397 // closest position to the target column
392398 index_type* closest_position =
0 commit comments