[Rd] "getOption(max.print) omitted %d entries" may be negative
Martin Maechler
m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Mon Jan 3 18:15:20 CET 2022
>>>>> Hugh Parsonage
>>>>> on Wed, 29 Dec 2021 00:36:51 +1100 writes:
> In src/main/printvector.c in the definition of printVector and
> printNamedVector (and elsewhere):
> Rprintf(" [ reached getOption(\"max.print\") -- omitted %d entries ]\n",
> n - n_pr);
> Though n - n_pr is of type R_xlen_t so may not be representable as
> int. In practice negative values may be observed for long vectors.
> Rprintf(" [ reached getOption(\"max.print\") -- omitted %lld entries ]\n",
> n - n_pr);
Thank you Hugh, for finding and reporting this,
including a proposed remedy.
At some point in time, I think the %lld format specifier was
not portable enough to all versions of C compiler / libraries
that were considered valid for compiling R.
See e.g.,
https://stackoverflow.com/questions/462345/format-specifier-for-long-long
which says that "it" does not work on Windows.
Maybe this has changed now that we require C99 and also that
since R version 4.0.0 (or 4.0.1) we also use a somewhat more
recent version of gcc also on Windows?
... ah, searching the R sources reveals uses of %lld
*plus*
#ifdef Win32
#include <trioremap.h> /* for %lld */
#endif
so it seems we can and should probably change this ...
[Please, C compiler / library standard experts, chime in !]
Martin Maechler
ETH Zurich and R core team
More information about the R-devel
mailing list