rchk icon indicating copy to clipboard operation
rchk copied to clipboard

False positive with Boost's integrators

Open andrjohns opened this issue 6 months ago • 0 comments

I'm seeing an rchk false positive with the following function which uses one of the integrators from Boost:

#include <cpp11.hpp>
#include <cpp11/declarations.hpp>
#include <boost/math/quadrature/tanh_sinh.hpp>
#include <cmath>

extern "C" {
  SEXP tanh_sinh_() {
    BEGIN_CPP11

    auto func = [](double x) { return std::log(x)*std::log1p(-x); };

    boost::math::quadrature::tanh_sinh<double> integrator;
    double result = integrator.integrate(func, 0, 1);

    return cpp11::as_sexp(result);

    END_CPP11
  }
}

Where rchk returns:

Function tanh_sinh_
  [UP] unprotected variable <unnamed var:   %1 = alloca %struct.SEXPREC*, align 8> while calling allocating function boost::math::quadrature::tanh_sinh<double, boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> 

I've put together a minimal reprex package here: https://github.com/andrjohns/rchktest

Let me know if you need any more info, thanks!

andrjohns avatar Jun 27 '25 18:06 andrjohns