[Rcpp-devel] UBSAN warning

Jan van der Laan rhelp at eoos.dds.nl
Mon Jul 2 16:40:06 CEST 2018

Judging from the name of the object in which the error occurs, I suspect 
it is in a line in which you compare a R-vector with a single (double) 

The error is in the function

	inline int rhs_is_not_na(int i) const {
		STORAGE x = lhs[i] ;
		return Rcpp::traits::is_na<RTYPE>(x) ? x : op( x, rhs ) ;

This functions seems to return the left hand side of the operator, when 
the left hand value is NA. Guess this could result in the message you 
see when the left hand value is a double.

Looking at your code I see

if (bandwidth < 0.0)
   Rcpp::stop("bandwidth needs to be non-negative");

if (!R_FINITE(bandwidth))
   Rcpp::stop("inappropriate value of bandwidth");

https://github.com/twolodzko/kernelboot/blob/master/src/univar-kd.cpp. I 
would make more sense to first test for NA and then for < 0.0.


On 30-06-18 21:56, Timothy wrote:
> Hi,
> I maintain a package on CRAN. Recently I posted an update and was asked 
> about UBSAN warning produced during checks of the previous version:
> https://www.stats.ox.ac.uk/pub/bdr/memtests/clang-UBSAN/kernelboot/tests/testthat.Rout
> It is not clear for me where does the warning come from, could you give 
> me some hints what could it be? The warning message seems to relate to 
> Rcpp itself, isn't it? If not, what is the best way of diagnosing causes 
> of such warnings?
> Thanks in advance,
> Timothy
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

More information about the Rcpp-devel mailing list