Opened 10 years ago

Closed 10 years ago

#8162 closed Bugs (fixed)

lexical_cast is using math::changesign with long double regardless of whether BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is defined or not.

Reported by: Eric Niebler Owned by: Antony Polukhin
Milestone: Boost 1.54.0 Component: lexical_cast
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

Line 1399-1400 of boost::lexical_cast looks like this:

long double result = std::pow(10.0L, pow_of_10) * mantissa;
value = static_cast<T>( has_minus ? (boost::math::changesign)(result) : result);

It turns out that this causes problems in the guts of Boost.Math when BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS is defined. This is causing Boost.Test build failures. See for instance http://tinyurl.com/af5453h, which at the time of writing shows:

    "g++"  -ftemplate-depth-128 -O0 -fno-inline -Wall -g -ftemplate-depth-1024 -DBOOST_ALL_NO_LIB=1 -DBOOST_TEST_NO_AUTO_LINK=1  -I".." -c -o "/usr/home/jim/boost_rt/trunk/results/boost/bin.v2/libs/xpressive/test/c_traits.test/gcc-4.2.1/debug/link-static/c_traits.o" "../libs/xpressive/test/c_traits.cpp"

In file included from ../libs/xpressive/test/./regress.ipp:19,
                 from ../libs/xpressive/test/c_traits.cpp:15:
../boost/math/tools/promotion.hpp: In instantiation of 'boost::math::tools::promote_args<long double, float, float, float, float, float>':
../boost/lexical_cast.hpp:1400:   instantiated from here
../boost/math/tools/promotion.hpp:141: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>' }}}

Aside: there is no entry for lexical_cast in libs/maintainers.txt. There should be.

Change History (3)

comment:1 by Antony Polukhin, 10 years ago

(In [83113]) Add entry for lexical_cast library to maintainers.txt (refs #8162)

comment:2 by Antony Polukhin, 10 years ago

(In [83129]) Do not use long double type in lexical_cast for internal variables if Boost.Math has no functions for long double (refs #8162) Do not test lexical_cast on long doubles, if Boost.Math does not support long double

comment:3 by Antony Polukhin, 10 years ago

Resolution: fixed
Status: newclosed

(In [83542]) Merge from trunk:

  • Fixed incorrect usage of Boost.Math when it does not support long double (fixes #8162)
  • Fixed ambiguity of boost::lexical_cast functions (fixes #7421)
Note: See TracTickets for help on using tickets.