Hi again,
I realised it is useful to replicate the warnings locally without relying on
CRAN automatic check; instead of R(-devel) CMD check --as-cran
package_version.tar.gz one can use
R CMD check --configure-args=""
and in my case the WARNINGS were initially given with
https://www.stats.ox.ac.uk/pub/bdr/gcc9/README.txt and those specification might
as well used in --configure-args above.
Besst regards,
Jing Hua
________________________________
From: R-devel <r-devel-bounces at r-project.org> on behalf of jing hua
zhao <jinghuazhao at hotmail.com>
Sent: 29 May 2019 15:49
To: r-devel at r-project.org
Subject: [Rd] use of buffers in sprintf and snprintf
Dear R-developers,
I am struggling with packaging with sprintf and snprintf() as the following
WARNINGS from gcc 9.x,
hap_c.c:380:46: warning: ?%d? directive output may be truncated writing
between 1 and 10 bytes into a region of size between 0 and 127
[-Wformat-truncation=]
hap_c.c:392:46: warning: ?%d? directive output may be truncated writing
between 1 and 10 bytes into a region of size between 0 and 127
[-Wformat-truncation=]
Essentially, I have
#define MAX_FILENAME_LEN 128
char of1name[MAX_FILENAME_LEN],of2name[MAX_FILENAME_LEN],
tempname[MAX_FILENAME_LEN];
...
snprintf(tempname,sizeof(tempname),"%s.%d", of1name, j);
It looks I could get around with
#define MAX_FILENAME_LEN 128
#define MAX_FILENAME_LEN2 256
char of1name[MAX_FILENAME_LEN],of2name[MAX_FILENAME_LEN],
tempname[MAX_FILENAME_LEN2];
...
snprintf(tempname,2*sizeof(tempname)+1,"%s.%d", of1name, j)
It looks a bit waste of resources to me.
Any idea will be greatly appreciated,
Jing Hua
[[alternative HTML version deleted]]
[[alternative HTML version deleted]]
Dear R-developers, I am keen to calculate exp(z*z/2) with z=qnorm(p/2) and p is very small. I wonder if anyone has experience with this? Thanks very much in advance, Jing Hua [[alternative HTML version deleted]]
Hello, Well, try it: p <- .Machine$double.eps^seq(0.5, 1, by = 0.05) z <- qnorm(p/2) pnorm(z) # [1] 7.450581e-09 1.228888e-09 2.026908e-10 3.343152e-11 5.514145e-12 # [6] 9.094947e-13 1.500107e-13 2.474254e-14 4.080996e-15 6.731134e-16 #[11] 1.110223e-16 p/2 # [1] 7.450581e-09 1.228888e-09 2.026908e-10 3.343152e-11 5.514145e-12 # [6] 9.094947e-13 1.500107e-13 2.474254e-14 4.080996e-15 6.731134e-16 #[11] 1.110223e-16 exp(z*z/2) # [1] 9.184907e+06 5.301421e+07 3.073154e+08 1.787931e+09 1.043417e+10 # [6] 6.105491e+10 3.580873e+11 2.104460e+12 1.239008e+13 7.306423e+13 #[11] 4.314798e+14 p is the smallest possible such that 1 + p != 1 and I couldn't find anything to worry about. R version 3.6.0 (2019-04-26) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 19.04 Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.8.0 LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.8.0 locale: [1] LC_CTYPE=pt_PT.UTF-8 LC_NUMERIC=C [3] LC_TIME=pt_PT.UTF-8 LC_COLLATE=pt_PT.UTF-8 [5] LC_MONETARY=pt_PT.UTF-8 LC_MESSAGES=pt_PT.UTF-8 [7] LC_PAPER=pt_PT.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=pt_PT.UTF-8 LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods [7] base other attached packages: [many packages loaded] Hope this helps, Rui Barradas ?s 15:24 de 21/06/19, jing hua zhao escreveu:> Dear R-developers, > > I am keen to calculate exp(z*z/2) with z=qnorm(p/2) and p is very small. I wonder if anyone has experience with this? > > Thanks very much in advance, > > > Jing Hua > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >