[Rcpp-devel] Rcpp example that crashes on 64 bit Windows
Rajen Shah
rds37 at cam.ac.uk
Thu Aug 11 15:05:42 CEST 2016
Dear Dirk,
Many thanks. So I'm concluding that wrap is not meant to do casting in this
sense but rather converts non-SEXP to SEXP, and so crashing is not
unexpected.
Best,
Rajen
On 11 August 2016 at 07:43, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> 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 at lists.r-forge.r-project.org
> | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20160811/d4129a74/attachment.html>
More information about the Rcpp-devel
mailing list