File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -261,19 +261,23 @@ static inline void
261261matrix_transpose_double (double * restrict dst , const double * restrict src ,
262262 const size_t nrows , const size_t ncols )
263263{
264- ASSUME (nrows < SIZE_MAX /2 && ncols < SIZE_MAX /2 );
265- if (nrows <= 0 || ncols <= 0 )
264+ // Make sure that nrows * (ncols + 1) < SIZE_MAX
265+ ASSUME (nrows < SIZE_MAX / (ncols + 1 ) && (ncols + 1 ) < SIZE_MAX / nrows );
266+ if (nrows == 0 || ncols == 0 )
266267 return ;
267268
268269 const size_t len_1 = (nrows * ncols ) - 1 ;
269270 size_t i = 0 , j = 0 ;
270271 for (; j <= len_1 ; i ++ , j += nrows )
271272 dst [j ] = src [i ];
272273
273- for (; i <= len_1 ; i ++ , j += nrows ) {
274- if (j > len_1 ) j -= len_1 ;
275- dst [j ] = src [i ];
276- }
274+ // FIXME: https://gcc.gnu.org/PR125293
275+ j -= len_1 ;
276+ while (i <= len_1 ) {
277+ for (; j <= len_1 ; i ++ , j += nrows )
278+ dst [j ] = src [i ];
279+ j -= len_1 ;
280+ }
277281}
278282
279283SEXP
You can’t perform that action at this time.
0 commit comments