[Rcpp-devel] Segfaults

Hadley Wickham hadley at rice.edu
Wed Jan 4 15:33:19 CET 2012


Hi all,

Is it a bug to cause a segfault with Rcpp? Or are am I doing something
so dumb that an automatic check could never protect?  See minimal
reproducible example below.

Hadley

library(inline)
f <- cxxfunction(signature(x = "numeric", i = "numeric"), plugin = "Rcpp", '
  Rcpp::NumericVector x_(x);
  Rcpp::NumericVector i_(i);

  x_[(int) (i_[0]) - 1] = 1000;

  return(x_);
')
f(1:10, 1) # works
f(1:10, 1.5) # also works
f(1:10, NA) # segfaults

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/


More information about the Rcpp-devel mailing list