Skip to content

Commit 7da8ae0

Browse files
committed
Cast matrix size to R_xlen_t to support long vectors
The individual indices for matrices in R are of type int, but the size is potentially larger than that. R_xlen_t is used for the product of the number of ros and columns.
1 parent 5a15c12 commit 7da8ae0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

inst/include/RcppEigenWrap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ namespace Rcpp{
8787
T::ColsAtCompileTime>,
8888
const T&>::type objCopy(obj);
8989
int m = obj.rows(), n = obj.cols();
90-
SEXP ans = PROTECT(::Rcpp::wrap(objCopy.data(), objCopy.data() + m * n));
90+
R_xlen_t size = std::static_cast<R_xlen_t>(m) * n;
91+
SEXP ans = PROTECT(::Rcpp::wrap(objCopy.data(), objCopy.data() + size));
9192
if( T::ColsAtCompileTime != 1 ) {
9293
SEXP dd = PROTECT(::Rf_allocVector(INTSXP, 2));
9394
int *d = INTEGER(dd);

0 commit comments

Comments
 (0)