On 11 August 2016 at 06:28, Rajen Shah wrote: | Hello, | | I am having trouble debugging a package that appears to work fine on Mac | operating systems but crashes on Unix and Windows. | | I have found the following example that crashes on my Windows setup (session | info copied below) | | IntegerVector runif_int2() { | return wrap(floor(runif(1000000))); | } | | When this is called about 5-10 times in succession R crashes (e.g. with | set.seed(1), but this doesn't seem to matter). | | Any ideas about why this crashes would be much appreciated. To be clear, I am | not looking for an alternative to the above code (which simply produces a | vector of zeroes), but would like to know what aspects of this cause a crash so | I know what code structures may be causing problems in the package I am | creating. The code does not appear to crash on Mac and I have yet to try it on | Unix.
i) On my box it doesn't run (which is probably a bug) R> library(Rcpp) R> cppFunction("IntegerVector runif_int2() { return wrap(floor(runif(1000000))); }") R> set.seed(1) R> replicate(100, runif_int2()) ## should probably use loop here... Error in runif_int2() : unimplemented type 'integer' in 'coerceToInteger' R> ii) Your code is still "wrong" or less than ideal. You really are working with doubles there, even after the floor() around runif. So maybe return a double vector? Else assign explictly via a cast. Dirk | | Many thanks in advance, | | Rajen | | Session info: | | R version 3.3.1 (2016-06-21) | Platform: x86_64-w64-mingw32/x64 (64-bit) | Running under: Windows >= 8 x64 (build 9200) | | locale: | [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 | LC_MONETARY=English_United States.1252 | [4] LC_NUMERIC=C LC_TIME=English_United States.1252 | | | attached base packages: | [1] stats graphics grDevices utils datasets methods base | | loaded via a namespace (and not attached): | [1] tools_3.3.1 | _______________________________________________ | Rcpp-devel mailing list | Rcpp-devel@lists.r-forge.r-project.org | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel