Skip to content
Prev 9640 / 10988 Next

[Rcpp-devel] Call to function through pointer to incorrect function type on UBSAN

I can't replicate the reported UBSAN issues on my macOS machine (R-devel
compiled with LLVM clang 4.0.1, with address + undefined behavior
sanitizers active).

The warnings look somewhat dubious to me: for example, the first warning:

function_pointers.h:99:12: runtime error: call to function
a1_fn(arma::Col<double> const&, arma::Col<double> const&) through
pointer to incorrect function type 'arma::Col<double> (*)(const
arma::Col<double> &, const arma::Col<double> &)'
/tmp/RtmpObvRHm/sourceCpp-x86_64-pc-linux-gnu-0.12.11/sourcecpp_96075e756157/growth_model_functions.cpp:7:
note: a1_fn(arma::Col<double> const&, arma::Col<double> const&)
defined here

If I'm reading that correctly, you have the following types:

Pointer:                      (arma::Col<double> const&,
arma::Col<double> const& )
Actual:  arma::Col<double> (*)(const arma::Col<double> &, const
arma::Col<double> &)

and those look compatible to me (the only difference is the ordering of the
'const &' printing in each case).

Unless I'm missing something obvious, it seems like this might just be a
bug in the version of UBSAN used on the CRAN build machines? The fact that
this error is not seen with gcc, only with clang, supports that hypothesis,
so I think you can safely ignore those errors. (Perhaps this was a bug in
Clang 4.0.0 that was fixed in Clang 4.0.1)

Kevin
On Fri, Jul 7, 2017 at 2:58 PM, Helske, Jouni <jouni.helske at jyu.fi> wrote:

            
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170708/804fda16/attachment.html>