Repository navigation
Consider -Wconversion warnings #1488
Description
Activity
This is with gcc 16.1.1 install.log
- 60 (unique) conversion warnings
- 108 (unique) sign conversion warnings
If we add the warnings from the tests and restrict the search to "may change" (value or the sign of the result), I get
- 2 unique conversion warnings
- 221 unique sign conversion warnings
The two 'may change value' are from code borrowed from base R (i.e. in
src/date.cpp). The oneintswitch to assize_t; we could borrow that. The other seems unchanges.All the others go away (under
clang++) when running-Wconversion -Wno-sign-conversionso on balance maybe there is nothing here for us to do.The bigger issue, that is also harder to tackle, is warnings we may tickle in client programs using a different / larger / other part of our headers than the (relatively small) package compilation of
Rcppitself does.Our tests have a pretty decent coverage, so I would say that the filtered log above is a good picture of what others may see.
But test compilation is 'silent' compared to the more visible compilation of files below
src/duringR CMD INSTALL.Ah, you are right, we only see the output for packages that are installed during the tests. I guess we could activate the verbose output for
sourceCppto get the wider picture.- added a parent issue
on Sep 1, 2026 Shall we close this one too? BDR still gets different warnings from a different compiler on a different platform (i.e.
clang++on arm64) but for our purposes all of-Wextrafromgccis covered.Let me give it a go to see if there's something useful there.
Reacted by Dirk EddelbuettelIndependently of what clang may find, activating
-Wconversionwith gcc gives a lot of insight, because it uncovers some potentially buggy places (some real bugs too) where there's ambiguity or we are sloppy with the usage ofintandR_xlen_t. So PR coming, and I think it's worth it leaving this flag activated from now on.Yes. Lossy conversions are bad. My question was really concerned with the open issue as I do not like issue to linger :)
Enabling
-Wconversion(particularly withclang++as on the M1mac machine at CRAN, see its README) exposes a number of warnings. The Oxford machine usesclang++-21, on Ubuntu 26.04 we also haveclang++-22which Vienna uses (without the same options). Per the README this usesNote that this turns 'sign-conversion' warnings off. Those account for a ton. I found first set of changes we could make by not doing this i.e. by running with only
-Wconversion. That may be too radical, but it could still hide some overflows.Also, our own compilation is 'clean' under
-Wconversion -Wno-sign-conversionhowever other package may see