Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#6959 closed Patches (fixed)

call of abs is ambiguous

Reported by: Niklas Angare <li51ckf02@…> 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)

thread_sleep.patch (1.8 KB ) - added by Niklas Angare <li51ckf02@…> 10 years ago.

Download all attachments as: .zip

Change History (6)

by Niklas Angare <li51ckf02@…>, 10 years ago

Attachment: thread_sleep.patch added

comment:1 by viboes, 10 years ago

Thanks for the report. Could you tell me which one is missing return boost::report_errors();

comment:2 by viboes, 10 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned
Version: Boost 1.49.0Boost 1.50.0

OH, I see it now (libs/thread/test/threads/this_thread/sleep_until/sleep_until_pass.cpp )

comment:3 by viboes, 10 years ago

Milestone: To Be DeterminedBoost 1.51.0

Committed in trunk at revision 78802.

comment:4 by viboes, 10 years ago

Resolution: fixed
Status: assignedclosed

Merged to release branch.

comment:5 by viboes, 10 years ago

Milestone: Boost 1.51.0Boost 1.50.0
Note: See TracTickets for help on using tickets.