I would expect parallel:::splitIndices(0L, ncl) to return integer(0). Instead, it returns a list, some of whose elements contain a value.
This appears to be an instance of the common 1:n-where-n-is-0 bug.
Changing the line i <- 1L:nx to i <- seq_len(nx) provides a fix.
A related problem is when the ncl input is zero. It isn't entirely clear if clusters with no nodes should be allowed, and some thought about how they are handled throughout the package is needed. In the meantime, since makeCluster currently permits clusters with zero nodes, splitIndices needs to deal with that possibility. Here's a suggested update to the function:
splitIndices <- function(nx, ncl)
if(ncl < 1) return(list())
i <- seq_len(nx)
if (ncl == 1L || nx <= 1L)
fuzz <- min((nx - 1L)/1000, 0.4 * nx/ncl)
breaks <- seq(1 - fuzz, nx + fuzz, length = ncl + 1L)
structure(split(i, cut(i, breaks)), names = NULL)
x <- splitIndices(5, 4)
identical(splitIndices(0, 4), integer()),
identical(splitIndices(5, 0), list()),
identical(splitIndices(0, 0), list())
Improved in R-devel and R-patched
*** Bug 15658 has been marked as a duplicate of this bug. ***