[R-pkg-devel] Rcpp specific Linux warning related to sprint function

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Fri Dec 6 12:06:54 CET 2019


On 06/12/2019 5:48 a.m., Sebastian SOSA wrote:
> Dear all,
> 
> I am trying to submit my R package on CRAN however I have a specific Linux warning message related to a Rcpp function I found online and included in my package:
> https://gallery.rcpp.org/articles/faster-data-frame-creation/
> 
> More specifically, the issue is related to sprint (lines 7 and 14) and is the following:
> list_to_df.cpp:40:28: warning: '%d' directive writing between 1 and 10 bytes into a region of size 4 [-Wformat-overflow=]
> 
> I don't know what this is about and it will be difficult to me to try to solve it as I am on a Windows machine. Thanks in advance for your help.

The message says that the value being written could be as long as 10 
bytes:  probably because int could be 64 bits.  You have declared the 
space to hold the result to be 5 bytes long (including the terminating 
null byte).  That assumes that the integer is less than 9999.

One solution would probably be to declare the name to be "char 
name[11]".  Even though you'll never see a dataframe big enough to need 
that, it will make the compiler happy.

Another solution might be to tell the compiler that you only handle 
values up to 9999; I don't know how to do that.

Duncan Murdoch



More information about the R-package-devel mailing list