Boost C++ Libraries: Ticket #6959: call of abs is ambiguous https://svn.boost.org/trac10/ticket/6959 <p> The regression tests this_thread__sleep_for_p* and this_thread__sleep_until_p* fail to compile on QNX 6.5.0: </p> <pre class="wiki">sleep_for_pass.cpp:38: error: call of overloaded 'abs(long int)' is ambiguous </pre><p> Here's the troublesome line: </p> <pre class="wiki">BOOST_TEST(std::abs(static_cast&lt;long&gt;(ns.count())) &lt; (err+boost::chrono::milliseconds(1000)).count()); </pre><p> I'm thinking that it might be a compiler bug but either way it should be easy to work around. </p> <p> 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: </p> <pre class="wiki">BOOST_TEST(std::max(ns, -ns) &lt; (err+boost::chrono::milliseconds(1000))); </pre><p> These also work but have the overflow problem: </p> <pre class="wiki">BOOST_TEST(std::abs(static_cast&lt;int&gt;(ns.count())) &lt; (err+boost::chrono::milliseconds(1000)).count()); </pre><pre class="wiki">BOOST_TEST(std::labs(static_cast&lt;long&gt;(ns.count())) &lt; (err+boost::chrono::milliseconds(1000)).count()); </pre><p> As a side note; one of the tests end with <em>return boost::report_errors()</em> while the other one doesn't. Bug? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6959 Trac 1.4.3 Niklas Angare <li51ckf02@…> Sat, 02 Jun 2012 19:14:08 GMT attachment set https://svn.boost.org/trac10/ticket/6959 https://svn.boost.org/trac10/ticket/6959 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">thread_sleep.patch</span> </li> </ul> Ticket viboes Sat, 02 Jun 2012 21:51:23 GMT <link>https://svn.boost.org/trac10/ticket/6959#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6959#comment:1</guid> <description> <p> Thanks for the report. Could you tell me which one is missing return boost::report_errors(); </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 02 Jun 2012 21:54:01 GMT</pubDate> <title>owner, status, version changed https://svn.boost.org/trac10/ticket/6959#comment:2 https://svn.boost.org/trac10/ticket/6959#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost 1.49.0</span> → <span class="trac-field-new">Boost 1.50.0</span> </li> </ul> <p> OH, I see it now (libs/thread/test/threads/this_thread/sleep_until/sleep_until_pass.cpp ) </p> Ticket viboes Sun, 03 Jun 2012 18:13:12 GMT milestone changed https://svn.boost.org/trac10/ticket/6959#comment:3 https://svn.boost.org/trac10/ticket/6959#comment:3 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.51.0</span> </li> </ul> <p> Committed in trunk at revision 78802. </p> Ticket viboes Thu, 21 Jun 2012 21:16:47 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6959#comment:4 https://svn.boost.org/trac10/ticket/6959#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Merged to release branch. </p> Ticket viboes Thu, 21 Jun 2012 21:18:19 GMT milestone changed https://svn.boost.org/trac10/ticket/6959#comment:5 https://svn.boost.org/trac10/ticket/6959#comment:5 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.51.0</span> → <span class="trac-field-new">Boost 1.50.0</span> </li> </ul> Ticket