diff --git a/include/boost/decimal/charconv.hpp b/include/boost/decimal/charconv.hpp index a60a783d1..ac6dc708f 100644 --- a/include/boost/decimal/charconv.hpp +++ b/include/boost/decimal/charconv.hpp @@ -190,7 +190,7 @@ constexpr auto to_chars_nonfinite(char* first, char* last, const TargetDecimalTy } } - return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE : Should be unreachable + return {last, std::errc::value_too_large}; case FP_NAN: if (issignaling(value) && buffer_len >= 9) { @@ -238,7 +238,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec // Dummy check the bounds if (BOOST_DECIMAL_UNLIKELY(buffer_size < real_precision)) { - return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE + return {last, std::errc::value_too_large}; } using uint_type = std::conditional_t<(std::numeric_limits::digits > @@ -253,7 +253,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec // which we have already checked for if (BOOST_DECIMAL_UNLIKELY(!r)) { - return r; // LCOV_EXCL_LINE + return r; } auto current_digits {r.ptr - (first + 1)}; @@ -273,7 +273,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec const auto total_length {total_buffer_length(static_cast(current_digits), exp, is_neg)}; if (BOOST_DECIMAL_UNLIKELY(total_length > buffer_size)) { - return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE + return {last, std::errc::value_too_large}; } // Insert our decimal point (or don't in the 1 digit case) @@ -309,7 +309,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec if (BOOST_DECIMAL_UNLIKELY(!exp_r)) { - return exp_r; // LCOV_EXCL_LINE + return exp_r; } return {exp_r.ptr, std::errc{}}; @@ -374,7 +374,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec } else if (significand_digits > local_precision + 1) { - const auto original_sig = significand; // LCOV_EXCL_LINE : False negative + const auto original_sig = significand; fenv_round(significand); if (remove_trailing_zeros(original_sig + 1U).trimmed_number == 1U) { @@ -406,7 +406,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec // Only real reason we will hit this is a buffer overflow if (BOOST_DECIMAL_UNLIKELY(!r)) { - return r; // LCOV_EXCL_LINE + return r; } const auto current_digits = r.ptr - (first + 1) - 1; @@ -478,7 +478,7 @@ constexpr auto to_chars_scientific_impl(char* first, char* last, const TargetDec r = to_chars_integer_impl(first, last, abs_exp); if (BOOST_DECIMAL_UNLIKELY(!r)) { - return r; // LCOV_EXCL_LINE + return r; } return {r.ptr, std::errc()}; @@ -520,7 +520,7 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT if (BOOST_DECIMAL_UNLIKELY(!r)) { - return r; // LCOV_EXCL_LINE + return r; } const auto num_digits {r.ptr - current}; @@ -536,7 +536,7 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT { if (BOOST_DECIMAL_UNLIKELY(buffer_size < (current - first) + num_digits + exp)) { - return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE + return {last, std::errc::value_too_large}; } detail::memset(r.ptr, '0', static_cast(exp)); @@ -546,7 +546,7 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT { if (BOOST_DECIMAL_UNLIKELY(buffer_size < (current - first) + num_digits + 1)) { - return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE + return {last, std::errc::value_too_large}; } const auto decimal_pos {num_digits - abs_exp}; @@ -560,7 +560,7 @@ constexpr auto to_chars_fixed_impl(char* first, char* last, const TargetDecimalT const auto leading_zeros {abs_exp - num_digits}; if (BOOST_DECIMAL_UNLIKELY(buffer_size < (current - first) + 2 + leading_zeros + num_digits)) { - return {last, std::errc::value_too_large}; // LCOV_EXCL_LINE + return {last, std::errc::value_too_large}; } detail::memmove(current + 2 + leading_zeros, current, static_cast(num_digits)); diff --git a/include/boost/decimal/cstdio.hpp b/include/boost/decimal/cstdio.hpp index f5d2a9140..8f0d4753d 100644 --- a/include/boost/decimal/cstdio.hpp +++ b/include/boost/decimal/cstdio.hpp @@ -216,10 +216,8 @@ inline auto snprintf_impl(char* buffer, const std::size_t buf_size, const char* if (!r) { - // LCOV_EXCL_START errno = static_cast(r.ec); return -1; - // LCOV_EXCL_STOP } // Adjust the capitalization and locale @@ -287,7 +285,6 @@ inline auto fprintf(std::FILE* buffer, const char* format, const T... values) no } else { - // LCOV_EXCL_START // Add 50% overage in case we need to do locale conversion std::unique_ptr longer_char_buffer(new(std::nothrow) char[(3 * (format_len + value_space + 1)) / 2]); if (longer_char_buffer == nullptr) @@ -301,7 +298,6 @@ inline auto fprintf(std::FILE* buffer, const char* format, const T... values) no { bytes += static_cast(std::fwrite(longer_char_buffer.get(), sizeof(char), static_cast(bytes), buffer)); } - // LCOV_EXCL_STOP } return bytes; diff --git a/include/boost/decimal/cstdlib.hpp b/include/boost/decimal/cstdlib.hpp index 81cbefbc5..937d717ba 100644 --- a/include/boost/decimal/cstdlib.hpp +++ b/include/boost/decimal/cstdlib.hpp @@ -73,7 +73,7 @@ inline auto strtod_calculation(const char* str, char** endptr, char* buffer, con { if (significand) { - d = std::numeric_limits::signaling_NaN(); // LCOV_EXCL_LINE : False negative + d = std::numeric_limits::signaling_NaN(); } else { @@ -125,11 +125,8 @@ inline auto strtod_impl(const char* str, char** endptr) noexcept -> TargetDecima std::unique_ptr buffer(new(std::nothrow) char[str_length + 1]); if (buffer == nullptr) { - // Hard to get coverage on memory exhaustion - // LCOV_EXCL_START errno = ENOMEM; return std::numeric_limits::quiet_NaN(); - // LCOV_EXCL_STOP } auto d = strtod_calculation(str, endptr, buffer.get(), str_length); @@ -148,7 +145,7 @@ inline auto wcstod_calculation(const wchar_t* str, wchar_t** endptr, char* buffe if (BOOST_DECIMAL_UNLIKELY(val > 255)) { // Character can not be converted - return std::numeric_limits::quiet_NaN(); // LCOV_EXCL_LINE + return std::numeric_limits::quiet_NaN(); } buffer[i] = static_cast(val); @@ -188,11 +185,8 @@ inline auto wcstod_impl(const wchar_t* str, wchar_t** endptr) noexcept -> Target std::unique_ptr buffer(new(std::nothrow) char[str_length + 1]); if (buffer == nullptr) { - // Hard to get coverage on memory exhaustion - // LCOV_EXCL_START errno = ENOMEM; return std::numeric_limits::quiet_NaN(); - // LCOV_EXCL_STOP } return wcstod_calculation(str, endptr, buffer.get(), str_length); diff --git a/include/boost/decimal/detail/cmath/atan.hpp b/include/boost/decimal/detail/cmath/atan.hpp index d4dd82286..28246eb78 100644 --- a/include/boost/decimal/detail/cmath/atan.hpp +++ b/include/boost/decimal/detail/cmath/atan.hpp @@ -48,7 +48,7 @@ constexpr auto atan_impl(const T x) noexcept #ifndef BOOST_DECIMAL_FAST_MATH else if (fpc == FP_INFINITE) { - result = my_pi_half; // LCOV_EXCL_LINE False negative + result = my_pi_half; } #endif else diff --git a/include/boost/decimal/detail/cmath/tgamma.hpp b/include/boost/decimal/detail/cmath/tgamma.hpp index 6929d91d4..fe3222c5b 100644 --- a/include/boost/decimal/detail/cmath/tgamma.hpp +++ b/include/boost/decimal/detail/cmath/tgamma.hpp @@ -50,7 +50,7 @@ constexpr auto tgamma_impl(const T x) noexcept } else { - result = x; // LCOV_EXCL_LINE : False negative + result = x; } #endif } @@ -58,7 +58,7 @@ constexpr auto tgamma_impl(const T x) noexcept { // Pure negative integer argument. #ifndef BOOST_DECIMAL_FAST_MATH - result = std::numeric_limits::quiet_NaN(); // LCOV_EXCL_LINE : False negative + result = std::numeric_limits::quiet_NaN(); #else result = T{0}; #endif diff --git a/include/boost/decimal/detail/fast_float/compute_float80_128.hpp b/include/boost/decimal/detail/fast_float/compute_float80_128.hpp index 258fa5041..1eebab5c9 100644 --- a/include/boost/decimal/detail/fast_float/compute_float80_128.hpp +++ b/include/boost/decimal/detail/fast_float/compute_float80_128.hpp @@ -152,10 +152,8 @@ constexpr auto compute_float80_128(std::int64_t q, const Unsigned_Integer &w, if (BOOST_DECIMAL_UNLIKELY(ld == std::numeric_limits::infinity())) { - // LCOV_EXCL_START success = false; ld = 0.0L; - // LCOV_EXCL_STOP } return ld; diff --git a/include/boost/decimal/detail/fenv_rounding.hpp b/include/boost/decimal/detail/fenv_rounding.hpp index 7acf79dbd..724d7a7e6 100644 --- a/include/boost/decimal/detail/fenv_rounding.hpp +++ b/include/boost/decimal/detail/fenv_rounding.hpp @@ -229,7 +229,7 @@ constexpr auto coefficient_rounding(T1& coeff, T2& exp, T3& biased_exp, const bo if (coeff < std::numeric_limits::max()) { const auto smaller_coeff {static_cast(coeff)}; - const auto div_res {impl::divmod(smaller_coeff, static_cast(shift_pow_ten))}; // LCOV_EXCL_LINE : False negative since above and below are hit + const auto div_res {impl::divmod(smaller_coeff, static_cast(shift_pow_ten))}; shifted_coeff = static_cast(div_res.quotient); const auto trailing_digits {div_res.remainder}; sticky = trailing_digits != 0U; diff --git a/include/boost/decimal/detail/io.hpp b/include/boost/decimal/detail/io.hpp index 9500ef462..f8112f129 100644 --- a/include/boost/decimal/detail/io.hpp +++ b/include/boost/decimal/detail/io.hpp @@ -51,7 +51,6 @@ auto operator>>(std::basic_istream& is, DecimalType& d) if (BOOST_DECIMAL_UNLIKELY(t_buffer_len > static_buffer_size)) { - // LCOV_EXCL_START longer_char_buffer = std::unique_ptr(new(std::nothrow) char[t_buffer_len]); if (longer_char_buffer.get() == nullptr) { @@ -60,7 +59,6 @@ auto operator>>(std::basic_istream& is, DecimalType& d) } buffer = longer_char_buffer.get(); - // LCOV_EXCL_STOP } BOOST_DECIMAL_IF_CONSTEXPR (!std::is_same::value) @@ -108,7 +106,7 @@ auto operator>>(std::basic_istream& is, DecimalType& d) if (BOOST_DECIMAL_UNLIKELY(r.ec == std::errc::not_supported)) { - d = std::numeric_limits::signaling_NaN(); // LCOV_EXCL_LINE + d = std::numeric_limits::signaling_NaN(); } else if (static_cast(r.ec) == EINVAL) { @@ -166,7 +164,7 @@ auto operator<<(std::basic_ostream& os, const DecimalType& d) if (BOOST_DECIMAL_UNLIKELY(!r)) { - errno = static_cast(r.ec); // LCOV_EXCL_LINE + errno = static_cast(r.ec); } *r.ptr = '\0'; diff --git a/include/boost/decimal/detail/parser.hpp b/include/boost/decimal/detail/parser.hpp index e383044ad..bbeb4f8af 100644 --- a/include/boost/decimal/detail/parser.hpp +++ b/include/boost/decimal/detail/parser.hpp @@ -286,13 +286,10 @@ constexpr auto parser(const char* first, const char* last, bool& sign, Unsigned_ const from_chars_result r {from_chars_dispatch(significand_buffer, significand_buffer + offset, significand, base)}; switch (r.ec) { - // The two invalid cases are here for completeness, but I don't think we can actually hit them - // LCOV_EXCL_START case std::errc::invalid_argument: return {first, std::errc::invalid_argument}; case std::errc::result_out_of_range: return {next, std::errc::result_out_of_range}; - // LCOV_EXCL_STOP default: return {next, std::errc()}; } @@ -372,11 +369,8 @@ constexpr auto parser(const char* first, const char* last, bool& sign, Unsigned_ const from_chars_result r {from_chars_dispatch(significand_buffer, significand_buffer + offset, significand, base)}; switch (r.ec) { - // Out of range included for completeness, but I don't think we can actually reach it - // LCOV_EXCL_START case std::errc::result_out_of_range: return {next, std::errc::result_out_of_range}; - // LCOV_EXCL_STOP case std::errc::invalid_argument: return {first, std::errc::invalid_argument}; default: @@ -418,12 +412,10 @@ constexpr auto parser(const char* first, const char* last, bool& sign, Unsigned_ from_chars_result r = from_chars_dispatch(significand_buffer, significand_buffer + offset, significand, base); switch (r.ec) { - // LCOV_EXCL_START case std::errc::invalid_argument: return {first, std::errc::invalid_argument}; case std::errc::result_out_of_range: return {next, std::errc::result_out_of_range}; - // LCOV_EXCL_STOP default: break; } diff --git a/include/boost/decimal/detail/to_float.hpp b/include/boost/decimal/detail/to_float.hpp index a73412623..7a2bff654 100644 --- a/include/boost/decimal/detail/to_float.hpp +++ b/include/boost/decimal/detail/to_float.hpp @@ -94,10 +94,8 @@ BOOST_DECIMAL_CXX20_CONSTEXPR auto to_float(Decimal val) noexcept if (BOOST_DECIMAL_UNLIKELY(!success)) { - // LCOV_EXCL_START errno = EINVAL; return 0; - // LCOV_EXCL_STOP } return result; diff --git a/include/boost/decimal/dpd_conversion.hpp b/include/boost/decimal/dpd_conversion.hpp index 96253a876..e1c2abd54 100644 --- a/include/boost/decimal/dpd_conversion.hpp +++ b/include/boost/decimal/dpd_conversion.hpp @@ -761,7 +761,7 @@ constexpr auto to_dpd_d128(const DecimalType val) noexcept temp_sig /= 10U; } BOOST_DECIMAL_ASSERT(d[0] >= 0 && d[0] <= 9); - BOOST_DECIMAL_ASSERT(temp_sig == 0U); // LCOV_EXCL_LINE : False Negative + BOOST_DECIMAL_ASSERT(temp_sig == 0U); constexpr std::uint64_t leading_two_exp_bits_mask {0b11000000000000}; const auto leading_two_bits {(exp & leading_two_exp_bits_mask) >> 12U}; @@ -778,14 +778,12 @@ constexpr auto to_dpd_d128(const DecimalType val) noexcept const auto d0_is_nine {d[0] == 9}; switch (leading_two_bits) { - // LCOV_EXCL_START // The decimal128_t case never uses the combination field like the other types, // since the significand always fits inside the allotted number of bits. // I don't believe this path will ever be taken, but it's correct case 0U: combination_field_bits = d0_is_nine ? 0b11001 : 0b11000; break; - // LCOV_EXCL_STOP case 1U: combination_field_bits = d0_is_nine ? 0b11011 : 0b11010; break;