Subject: [Boost-bugs] [Boost C++ Libraries] #10104: program aborts with log1p(-2.0Q)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-06-07 12:49:49
#10104: program aborts with log1p(-2.0Q)
----------------------------------------+----------------------------
Reporter: Charles Karney <charles@â¦> | Owner: johnmaddock
Type: Bugs | Status: new
Milestone: To Be Determined | Component: multiprecision
Version: Boost 1.54.0 | Severity: Problem
Keywords: |
----------------------------------------+----------------------------
The math functions, e.g., log1p, for float128 do not handle parameters
outside the normal domain. Thus sqrt(-2.0Q) produces a nan as does
log1p(-2.0), but log1p(-2.0Q) crashes. (Similar remarks apply to hypot
and probably other similarly defined functions.)
{{{
#include <iostream>
#include <cmath>
#include <boost/multiprecision/float128.hpp>
#include <boost/math/special_functions/log1p.hpp>
int main() {
double x = -2;
boost::multiprecision::float128 y = -2;
std::cout << std::sqrt(x) << "\n" << std::log1p(x) << "\n";
std::cout << sqrt(y) << "\n";
std::cout << boost::math::log1p(y) << "\n";
}
}}}
produces
{{{
-nan
-nan
-nan
terminate called after throwing an instance of
'boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::domain_error>
>'
what(): Error in function
boost::math::log1p<N5boost14multiprecision6numberINS0_8backends16float128_backendELNS0_26expression_template_optionE0EEE>(N5boost14multiprecision6numberINS0_8backends16float128_backendELNS0_26expression_template_optionE0EEE):
log1p(x) requires x > -1, but got x = -2.
Aborted (core dumped)
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10104> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC