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

Jan Gorecki j@goreck| @end|ng |rom w|t@edu@p|
Thu Dec 31 11:08:08 CET 2020

Don't know this piece well but I am guessing that you haven't found an
example because the iterator is going up to the length of a vector
anymore but only to the number of batches, which is unlikely to be
more than 2^31.

On Tue, Dec 22, 2020 at 12:30 PM Suharto Anggono Suharto Anggono via
R-devel <r-devel using r-project.org> wrote:
> 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
> sum(x)
> for 'x' with storage mode "integer" and length 2^31 or more.
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

More information about the R-devel mailing list