[Rd] In function isum in summary.c, k should be R_xlen_t

Suharto Anggono Suharto Anggono @uh@rto_@nggono @end|ng |rom y@hoo@com
Tue Dec 22 11:30:14 CET 2020

In summary.c, in function 'isum', the loop is 'ITERATE_BY_REGION' that contains 'for' loop
for (int k = 0; k < nbatch; k++)
It is since SVN revision 73445, in released R since version 3.5.0.
Previously, the loop is
for (R_xlen_t i = 0; i < n; i++)

Inside 'ITERATE_BY_REGION', the type of the index, 'k', should still be 'R_xlen_t' as previously. If 'sx' is a regular vector (not ALTREP), data pointer is taken and 'nbatch' is the length of the vector, like without 'ITERATE_BY_REGION'. With 64-bit R, it is possible that the vector is a long vector. In that case, correct iteration should reach index outside the range of 'int'.

However, I haven't found an example in 64-bit R of wrong behavior of
for 'x' with storage mode "integer" and length 2^31 or more.

More information about the R-devel mailing list