Bug 17330 - [[<- for index 2^31 fails
Summary: [[<- for index 2^31 fails
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R 3.3.*
Hardware: x86_64/x64/amd64 (64-bit) Linux-Ubuntu
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2017-08-26 02:17 UTC by Suharto Anggono
Modified: 2017-08-31 17:15 UTC (History)
0 users

See Also:


Attachments
Against R-devel r73166, subscript.c: OneIndex: follow 'get1index' (817 bytes, patch)
2017-08-31 17:15 UTC, Suharto Anggono
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Suharto Anggono 2017-08-26 02:17:56 UTC
This fails.
x <- raw()
x[[2^31]] <- as.raw(1)

Result:
Error in x[[2^31]] <- as.raw(1) : 
  attempt to select less than one element in integerOneIndex

Also this.
x <- raw(2^31)
x[[2^31]] <- as.raw(1)

Result:
Error in x[[2^31]] <- as.raw(1) : 
  attempt to select more than one element in integerOneIndex

This succeeds.
x <- raw()
x[2^31] <- as.raw(1)

Output of sessionInfo() :
R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.1 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

It was in http://rextester.com/l/r_online_compiler .

It seems that the culprit is cast to int in this part of function 'OneIndex' in subscript.c.
	indx = integerOneIndex((int)REAL(s)[pos], len, call);

It is still like that in R devel r73136.
Comment 1 Suharto Anggono 2017-08-26 05:39:15 UTC
Extraction by '[[' succeeds.
x <- raw(2^31)
x[[2^31]]
Comment 2 Suharto Anggono 2017-08-31 17:15:13 UTC
Created attachment 2291 [details]
Against R-devel r73166, subscript.c: OneIndex: follow 'get1index'