Subject: [Boost-bugs] [Boost C++ Libraries] #6959: call of abs is ambiguous
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-06-02 19:13:47
#6959: call of abs is ambiguous
------------------------------------------------------+---------------------
Reporter: Niklas Angare <li51ckf02@â¦> | Owner: anthonyw
Type: Patches | Status: new
Milestone: To Be Determined | Component: thread
Version: Boost 1.49.0 | Severity: Problem
Keywords: |
------------------------------------------------------+---------------------
The regression tests this_thread!__sleep_for_p* and
this_thread!__sleep_until_p* fail to compile on QNX 6.5.0:
{{{
sleep_for_pass.cpp:38: error: call of overloaded 'abs(long int)' is
ambiguous
}}}
Here's the troublesome line:
{{{
BOOST_TEST(std::abs(static_cast<long>(ns.count())) <
(err+boost::chrono::milliseconds(1000)).count());
}}}
I'm thinking that it might be a compiler bug but either way it should be
easy to work around.
I guess the static_cast is a work-around for the fact that C++03 doesn't
have abs(long long). I'm attaching a patch with a more reliable solution,
with no risk of 32-bit overflow:
{{{
BOOST_TEST(std::max(ns, -ns) < (err+boost::chrono::milliseconds(1000)));
}}}
These also work but have the overflow problem:
{{{
BOOST_TEST(std::abs(static_cast<int>(ns.count())) <
(err+boost::chrono::milliseconds(1000)).count());
}}}
{{{
BOOST_TEST(std::labs(static_cast<long>(ns.count())) <
(err+boost::chrono::milliseconds(1000)).count());
}}}
As a side note; one of the tests end with ''return
boost::report_errors()'' while the other one doesn't. Bug?
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6959> 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:09 UTC