#6959 closed Patches (fixed)
call of abs is ambiguous
Reported by: | Owned by: | viboes | |
---|---|---|---|
Milestone: | Boost 1.50.0 | Component: | thread |
Version: | Boost 1.50.0 | Severity: | Problem |
Keywords: | Cc: | vicente.botet@… |
Description
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?
Attachments (1)
Change History (6)
by , 10 years ago
Attachment: | thread_sleep.patch added |
---|
comment:1 by , 10 years ago
comment:2 by , 10 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Version: | Boost 1.49.0 → Boost 1.50.0 |
OH, I see it now (libs/thread/test/threads/this_thread/sleep_until/sleep_until_pass.cpp )
comment:3 by , 10 years ago
Milestone: | To Be Determined → Boost 1.51.0 |
---|
Committed in trunk at revision 78802.
comment:5 by , 10 years ago
Milestone: | Boost 1.51.0 → Boost 1.50.0 |
---|
Thanks for the report. Could you tell me which one is missing return boost::report_errors();