Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling vector constructors with R_xlen_t or size_t values > 2³¹ fails in 64-bit R on Windows #804

Closed
krlmlr opened this issue Jan 18, 2018 · 0 comments

Comments

@krlmlr
Copy link
Contributor

krlmlr commented Jan 18, 2018

  • The value of (size_t)0x81000000 look correct when cast to double
  • I can't create a RawVector of that size, presumably because it's coerced to a 32-bit integer
  • Note the difference between sizeof.long and sizeof.pointer

Related: #459, #460, CC @kendonB.

.Machine$sizeof.long
#> [1] 4
.Machine$sizeof.pointer
#> [1] 8
f1 <- Rcpp::cppFunction("double f1() { R_xlen_t x = 0x81000000; return x; }")
f2 <- Rcpp::cppFunction("double f1() { size_t x = 0x81000000; return x; }")
f3 <- Rcpp::cppFunction("RawVector f3() { R_xlen_t x = 0x81000000; return RawVector(x); }")
f4 <- Rcpp::cppFunction("RawVector f4() { size_t x = 0x81000000; return RawVector(x); }")
f1()
#> [1] 2164260864
f2()
#> [1] 2164260864
f3()
#> Error in f3(): negative length vectors are not allowed
f4()
#> Error in f4(): negative length vectors are not allowed
Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.3 (2017-11-30)
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_United States.1252  
#>  tz       Europe/Berlin               
#>  date     2018-01-18
#> Packages -----------------------------------------------------------------
#>  package   * version date       source        
#>  backports   1.1.2   2017-12-13 CRAN (R 3.4.3)
#>  base      * 3.4.3   2017-12-06 local         
#>  compiler    3.4.3   2017-12-06 local         
#>  datasets  * 3.4.3   2017-12-06 local         
#>  devtools    1.13.4  2017-11-09 CRAN (R 3.4.2)
#>  digest      0.6.13  2017-12-14 CRAN (R 3.4.3)
#>  evaluate    0.10.1  2017-06-24 CRAN (R 3.4.0)
#>  graphics  * 3.4.3   2017-12-06 local         
#>  grDevices * 3.4.3   2017-12-06 local         
#>  htmltools   0.3.6   2017-04-28 CRAN (R 3.4.0)
#>  knitr       1.17    2017-08-10 CRAN (R 3.4.1)
#>  magrittr    1.5     2014-11-22 CRAN (R 3.3.2)
#>  memoise     1.1.0   2017-04-21 CRAN (R 3.4.0)
#>  methods   * 3.4.3   2017-12-06 local         
#>  Rcpp        0.12.14 2017-11-23 CRAN (R 3.4.2)
#>  rmarkdown   1.8     2017-11-17 CRAN (R 3.4.2)
#>  rprojroot   1.2-11  2017-12-18 local         
#>  stats     * 3.4.3   2017-12-06 local         
#>  stringi     1.1.6   2017-11-17 CRAN (R 3.4.2)
#>  stringr     1.2.0   2017-02-18 CRAN (R 3.4.0)
#>  tools       3.4.3   2017-12-06 local         
#>  utils     * 3.4.3   2017-12-06 local         
#>  withr       2.1.0   2017-11-01 CRAN (R 3.4.2)
#>  yaml        2.1.16  2017-12-12 CRAN (R 3.4.3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant