Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clang-15 warnings #831

Merged
merged 1 commit into from
Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion include/boost/math/concepts/std_real_concept.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ inline std::basic_istream<charT, traits>& operator>>(std::basic_istream<charT, t
} // namespace concepts
}}

#include <boost/math/tools/precision.hpp>
#include <boost/math/tools/big_constant.hpp>

namespace boost{ namespace math{
Expand Down
4 changes: 2 additions & 2 deletions include/boost/math/differentiation/lanczos_smoothing.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,8 @@ class discrete_lanczos_derivative {
discrete_lanczos_derivative& operator=(const discrete_lanczos_derivative&) = delete;

// Allow moves:
discrete_lanczos_derivative(discrete_lanczos_derivative&&) = default;
discrete_lanczos_derivative& operator=(discrete_lanczos_derivative&&) = default;
discrete_lanczos_derivative(discrete_lanczos_derivative&&) noexcept = default;
discrete_lanczos_derivative& operator=(discrete_lanczos_derivative&&) noexcept = default;

private:
std::vector<Real> m_f;
Expand Down
12 changes: 6 additions & 6 deletions include/boost/math/distributions/complement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct complemented2_type
const RealType& param;

private:
complemented2_type& operator=(const complemented2_type&);
complemented2_type& operator=(const complemented2_type&) = delete;
};

template <class Dist, class RealType1, class RealType2>
Expand All @@ -47,7 +47,7 @@ struct complemented3_type
const RealType1& param1;
const RealType2& param2;
private:
complemented3_type& operator=(const complemented3_type&);
complemented3_type& operator=(const complemented3_type&) = delete;
};

template <class Dist, class RealType1, class RealType2, class RealType3>
Expand All @@ -68,7 +68,7 @@ struct complemented4_type
const RealType2& param2;
const RealType3& param3;
private:
complemented4_type& operator=(const complemented4_type&);
complemented4_type& operator=(const complemented4_type&) = delete;
};

template <class Dist, class RealType1, class RealType2, class RealType3, class RealType4>
Expand All @@ -92,7 +92,7 @@ struct complemented5_type
const RealType3& param3;
const RealType4& param4;
private:
complemented5_type& operator=(const complemented5_type&);
complemented5_type& operator=(const complemented5_type&) = delete;
};

template <class Dist, class RealType1, class RealType2, class RealType3, class RealType4, class RealType5>
Expand All @@ -119,7 +119,7 @@ struct complemented6_type
const RealType4& param4;
const RealType5& param5;
private:
complemented6_type& operator=(const complemented6_type&);
complemented6_type& operator=(const complemented6_type&) = delete;
};

template <class Dist, class RealType1, class RealType2, class RealType3, class RealType4, class RealType5, class RealType6>
Expand Down Expand Up @@ -149,7 +149,7 @@ struct complemented7_type
const RealType5& param5;
const RealType6& param6;
private:
complemented7_type& operator=(const complemented7_type&);
complemented7_type& operator=(const complemented7_type&) = delete;
};

template <class Dist, class RealType>
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/distributions/hyperexponential.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ bool check_dist(char const* function, std::vector<RealT> const& probabilities, s
if (probabilities.size() != rates.size())
{
*presult = policies::raise_domain_error<RealT>(function,
"The parameters \"probabilities\" and \"rates\" must have the same length, but their size differ by: %1%.",
R"(The parameters "probabilities" and "rates" must have the same length, but their size differ by: %1%.)",
fabs(static_cast<RealT>(probabilities.size())-static_cast<RealT>(rates.size())),
pol);
return false;
Expand Down
4 changes: 2 additions & 2 deletions include/boost/math/distributions/kolmogorov_smirnov.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ RealType kolmogorov_smirnov_pdf_small_x(RealType x, RealType n, const Policy&) {
if (x2n*x2n == 0.0) {
return static_cast<RealType>(0);
}
while (1) {
while (true) {
delta = exp(-RealType(i+0.5)*RealType(i+0.5)*pi2/(2*x2n)) * (RealType(i+0.5)*RealType(i+0.5)*pi2 - x2n);

if (delta == 0.0)
Expand All @@ -164,7 +164,7 @@ inline RealType kolmogorov_smirnov_pdf_large_x(RealType x, RealType n, const Pol
RealType value = RealType(0), delta = RealType(0), last_delta = RealType(0);
RealType eps = policies::get_epsilon<RealType, Policy>();
int i = 1;
while (1) {
while (true) {
delta = 8*x*i*i*exp(-2*i*i*x*x*n);

if (delta == 0.0)
Expand Down
6 changes: 2 additions & 4 deletions include/boost/math/policies/error_handling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ void raise_error(const char* pfunction, const char* message)
msg += ": ";
msg += message;

E e(msg);
BOOST_MATH_THROW_EXCEPTION(e)
BOOST_MATH_THROW_EXCEPTION(E(msg))
}

template <class E, class T>
Expand Down Expand Up @@ -183,8 +182,7 @@ void raise_error(const char* pfunction, const char* pmessage, const T& val)
replace_all_in_string(message, "%1%", sval.c_str());
msg += message;

E e(msg);
BOOST_MATH_THROW_EXCEPTION(e)
BOOST_MATH_THROW_EXCEPTION(E(msg))
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/boost/math/policies/policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ struct normalise<policy<detail::forwarding_arg1, detail::forwarding_arg2>,
};

inline constexpr policy<> make_policy() noexcept
{ return policy<>(); }
{ return {}; }

template <class A1>
inline constexpr typename normalise<policy<>, A1>::type make_policy(const A1&) noexcept
Expand Down Expand Up @@ -948,7 +948,7 @@ struct method_error_check
{
using domain_error_type = typename Policy::domain_error_type;
using type = typename std::conditional<
(domain_error_type::value == throw_on_error) && (domain_error_type::value != user_error),
(domain_error_type::value == throw_on_error),
std::false_type,
std::true_type>::type;
};
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/quadrature/detail/exp_sinh_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class exp_sinh_detail
mutable std::vector<std::vector<Real>> m_weights;
std::size_t m_max_refinements;
#if !defined(BOOST_MATH_NO_ATOMIC_INT) && defined(BOOST_HAS_THREADS)
mutable boost::math::detail::atomic_unsigned_type m_committed_refinements;
mutable boost::math::detail::atomic_unsigned_type m_committed_refinements{};
mutable std::mutex m_mutex;
#else
mutable unsigned m_committed_refinements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class ooura_fourier_sin_detail {
Real rel_err_goal_;

#ifdef BOOST_HAS_THREADS
std::atomic<long> starting_level_;
std::atomic<long> starting_level_{};
#else
long starting_level_;
#endif
Expand Down Expand Up @@ -663,7 +663,7 @@ class ooura_fourier_cos_detail {
Real rel_err_goal_;

#ifdef BOOST_HAS_THREADS
std::atomic<long> starting_level_;
std::atomic<long> starting_level_{};
#else
long starting_level_;
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/quadrature/detail/sinh_sinh_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class sinh_sinh_detail
mutable std::vector<std::vector<Real>> m_weights;
std::size_t m_max_refinements;
#if !defined(BOOST_MATH_NO_ATOMIC_INT) && defined(BOOST_HAS_THREADS)
mutable boost::math::detail::atomic_unsigned_type m_committed_refinements;
mutable boost::math::detail::atomic_unsigned_type m_committed_refinements{};
mutable std::mutex m_mutex;
#else
mutable unsigned m_committed_refinements;
Expand Down
4 changes: 2 additions & 2 deletions include/boost/math/quadrature/detail/tanh_sinh_detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ class tanh_sinh_detail
mutable std::vector<std::vector<Real>> m_abscissas;
mutable std::vector<std::vector<Real>> m_weights;
mutable std::vector<std::size_t> m_first_complements;
std::size_t m_max_refinements, m_inital_row_length;
std::size_t m_max_refinements, m_inital_row_length{};
#if !defined(BOOST_MATH_NO_ATOMIC_INT) && defined(BOOST_HAS_THREADS)
mutable boost::math::detail::atomic_unsigned_type m_committed_refinements;
mutable boost::math::detail::atomic_unsigned_type m_committed_refinements{};
mutable std::mutex m_mutex;
#else
mutable unsigned m_committed_refinements;
Expand Down
8 changes: 4 additions & 4 deletions include/boost/math/quadrature/naive_monte_carlo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ class naive_monte_carlo
Real error_goal,
bool singular = true,
uint64_t threads = std::thread::hardware_concurrency(),
uint64_t seed = 0) noexcept : m_num_threads{threads}, m_seed{seed}
uint64_t seed = 0) noexcept : m_num_threads{threads}, m_seed{seed}, m_volume(1)
{
using std::numeric_limits;
using std::sqrt;
uint64_t n = bounds.size();
m_lbs.resize(n);
m_dxs.resize(n);
m_limit_types.resize(n);
m_volume = 1;

static const char* function = "boost::math::quadrature::naive_monte_carlo<%1%>";
for (uint64_t i = 0; i < n; ++i)
{
Expand Down Expand Up @@ -439,12 +439,12 @@ class naive_monte_carlo
uint64_t m_num_threads;
std::atomic<uint64_t> m_seed;
std::atomic<Real> m_error_goal;
std::atomic<bool> m_done;
std::atomic<bool> m_done{};
std::vector<Real> m_lbs;
std::vector<Real> m_dxs;
std::vector<detail::limit_classification> m_limit_types;
Real m_volume;
std::atomic<uint64_t> m_total_calls;
std::atomic<uint64_t> m_total_calls{};
// I wanted these to be vectors rather than maps,
// but you can't resize a vector of atomics.
std::unique_ptr<std::atomic<uint64_t>[]> m_thread_calls;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
int n, cache_offset;
long long log_scale;

hypergeometric_1F1_AS_13_3_7_tricomi_series operator=(const hypergeometric_1F1_AS_13_3_7_tricomi_series&);
hypergeometric_1F1_AS_13_3_7_tricomi_series operator=(const hypergeometric_1F1_AS_13_3_7_tricomi_series&) = delete;

void refill_cache()
{
Expand Down Expand Up @@ -559,9 +559,9 @@
*j *= ratio;
}

hypergeometric_1F1_AS_13_3_6_series();
hypergeometric_1F1_AS_13_3_6_series(const hypergeometric_1F1_AS_13_3_6_series&);
hypergeometric_1F1_AS_13_3_6_series& operator=(const hypergeometric_1F1_AS_13_3_6_series&);
hypergeometric_1F1_AS_13_3_6_series() = delete;
hypergeometric_1F1_AS_13_3_6_series(const hypergeometric_1F1_AS_13_3_6_series&) = delete;
hypergeometric_1F1_AS_13_3_6_series& operator=(const hypergeometric_1F1_AS_13_3_6_series&) = delete;
};

template <class T, class Policy>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{
}

explicit hypergeometric_1F1_recurrence_a_coefficients(const hypergeometric_1F1_recurrence_a_coefficients&) = default;
hypergeometric_1F1_recurrence_a_coefficients(const hypergeometric_1F1_recurrence_a_coefficients&) = default;

hypergeometric_1F1_recurrence_a_coefficients operator=(const hypergeometric_1F1_recurrence_a_coefficients&) = delete;

Expand Down Expand Up @@ -67,7 +67,7 @@
{
}

explicit hypergeometric_1F1_recurrence_b_coefficients(const hypergeometric_1F1_recurrence_b_coefficients&) = default;
hypergeometric_1F1_recurrence_b_coefficients(const hypergeometric_1F1_recurrence_b_coefficients&) = default;

hypergeometric_1F1_recurrence_b_coefficients& operator=(const hypergeometric_1F1_recurrence_b_coefficients&) = delete;

Expand Down Expand Up @@ -100,7 +100,7 @@
{
}

explicit hypergeometric_1F1_recurrence_small_b_coefficients(const hypergeometric_1F1_recurrence_small_b_coefficients&) = default;
hypergeometric_1F1_recurrence_small_b_coefficients(const hypergeometric_1F1_recurrence_small_b_coefficients&) = default;

hypergeometric_1F1_recurrence_small_b_coefficients operator=(const hypergeometric_1F1_recurrence_small_b_coefficients&) = delete;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ T inverse_students_t_body_series(T df, T u, const Policy& pol)
}

template <class T, class Policy>
T inverse_students_t(T df, T u, T v, const Policy& pol, bool* pexact = 0)
T inverse_students_t(T df, T u, T v, const Policy& pol, bool* pexact = nullptr)
{
//
// df = number of degrees of freedom.
Expand Down
4 changes: 2 additions & 2 deletions include/boost/math/special_functions/expm1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ namespace detail
int k;
const T m_x;
T m_term;
expm1_series(const expm1_series&);
expm1_series& operator=(const expm1_series&);
expm1_series(const expm1_series&) = delete;
expm1_series& operator=(const expm1_series&) = delete;
};

template <class T, class Policy, class tag>
Expand Down
1 change: 0 additions & 1 deletion include/boost/math/special_functions/heuman_lambda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <boost/math/special_functions/math_fwd.hpp>
#include <boost/math/special_functions/ellint_rj.hpp>
#include <boost/math/special_functions/ellint_rj.hpp>
#include <boost/math/special_functions/ellint_1.hpp>
#include <boost/math/special_functions/jacobi_zeta.hpp>
#include <boost/math/constants/constants.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/special_functions/legendre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ T legendre_p_prime_imp(unsigned l, T x, const Policy& pol, T* Pn
T p0 = 1;
T p1 = x;
T p_prime;
bool odd = l & 1;
bool odd = (l & 1 == 1);
// If the order is odd, we sum all the even polynomials:
if (odd)
{
Expand Down
7 changes: 3 additions & 4 deletions include/boost/math/special_functions/legendre_stieltjes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class legendre_stieltjes
std::ptrdiff_t n = m - 1;
std::ptrdiff_t q;
std::ptrdiff_t r;
bool odd = n & 1;
if (odd)
if (n & 1 == 1)
{
q = 1;
r = (n-1)/2 + 2;
Expand Down Expand Up @@ -75,7 +74,7 @@ class legendre_stieltjes
Real norm_sq() const
{
Real t = 0;
bool odd = m_m & 1;
bool odd = (m_m & 1 == 1);
for (size_t i = 1; i < m_a.size(); ++i)
{
if(odd)
Expand All @@ -101,7 +100,7 @@ class legendre_stieltjes
Real p1 = x;

Real Em;
bool odd = m_m & 1;
bool odd = (m_m & 1 == 1);
if (odd)
{
Em = m_a[1]*p1;
Expand Down
4 changes: 2 additions & 2 deletions include/boost/math/special_functions/log1p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ namespace detail
int k;
const T m_mult;
T m_prod;
log1p_series(const log1p_series&);
log1p_series& operator=(const log1p_series&);
log1p_series(const log1p_series&) = delete;
log1p_series& operator=(const log1p_series&) = delete;
};

// Algorithm log1p is part of C99, but is not yet provided by many compilers.
Expand Down
2 changes: 1 addition & 1 deletion include/boost/math/special_functions/sin_pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ inline T sin_pi_imp(T x, const Policy& pol)
if(x < 0)
return -sin_pi_imp(T(-x), pol);
// sin of pi*x:
bool invert;
if(x < 0.5)
return sin(constants::pi<T>() * x);
bool invert;
if(x < 1)
{
invert = true;
Expand Down
6 changes: 3 additions & 3 deletions include/boost/math/special_functions/ulp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ T ulp_imp(const T& val, const std::true_type&, const Policy& pol)

int fpclass = (boost::math::fpclassify)(val);

if(fpclass == (int)FP_NAN)
if(fpclass == FP_NAN)
{
return policies::raise_domain_error<T>(
function,
Expand Down Expand Up @@ -60,13 +60,13 @@ T ulp_imp(const T& val, const std::false_type&, const Policy& pol)

int fpclass = (boost::math::fpclassify)(val);

if(fpclass == (int)FP_NAN)
if(fpclass == FP_NAN)
{
return policies::raise_domain_error<T>(
function,
"Argument must be finite, but got %1%", val, pol);
}
else if((fpclass == (int)FP_INFINITE) || (fabs(val) >= tools::max_value<T>()))
else if((fpclass == FP_INFINITE) || (fabs(val) >= tools::max_value<T>()))
{
return (val < 0 ? -1 : 1) * policies::raise_overflow_error<T>(function, nullptr, pol);
}
Expand Down
4 changes: 2 additions & 2 deletions include/boost/math/tools/polynomial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class polynomial
typedef typename std::vector<T>::size_type size_type;

// construct:
polynomial(){}
polynomial()= default;

template <class U>
polynomial(const U* data, unsigned order)
Expand Down Expand Up @@ -379,7 +379,7 @@ class polynomial

T operator()(T z) const
{
return m_data.size() > 0 ? boost::math::tools::evaluate_polynomial(&m_data[0], z, m_data.size()) : T(0);
return m_data.size() > 0 ? boost::math::tools::evaluate_polynomial((m_data).data(), z, m_data.size()) : T(0);
}
std::vector<T> chebyshev() const
{
Expand Down
Loading