Boost C++ Libraries: Ticket #4327: warning C4244: conversion from '__int64' to 'long', possible loss of data https://svn.boost.org/trac10/ticket/4327 <p> The following warning appears on msvc-9.0express: </p> <pre class="wiki">compile-c-c++ ..\..\..\bin.v2\libs\thread\test\test_condition_notify_one.test\msvc-9.0express\debug\threading-multi\test_condition_notify_one.obj test_condition_notify_one.cpp C:\cygwin\boost\trunk\boost/thread/win32/thread_data.hpp(171) : warning C4244: 'argument' : conversion from '__int64' to 'long', possible loss of data test_condition_notify_one.cpp(116) : see reference to function template instantiation 'void boost::this_thread::sleep&lt;boost::date_time::subsecond_duration&lt;base_duration,frac_of_second&gt;&gt;(const TimeDuration &amp;)' being compiled with [ base_duration=boost::posix_time::time_duration, frac_of_second=0x03e8, TimeDuration=boost::date_time::subsecond_duration&lt;boost::posix_time::time_duration,0x03e8&gt; ] </pre><p> The context is the call to pin_to_zero when the duration is stored on something larger than a long. </p> <pre class="wiki"> template&lt;typename TimeDuration&gt; inline void sleep(TimeDuration const&amp; rel_time) { interruptible_wait(detail::pin_to_zero(rel_time.total_milliseconds())); } </pre><p> I guest that we need another pin_to_zero overloading or making the pin_to_zero generic. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4327 Trac 1.4.3 viboes Wed, 09 Jun 2010 19:05:35 GMT <link>https://svn.boost.org/trac10/ticket/4327#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:1</guid> <description> <p> In addition the function interruptible_wait needs to be refactored when the number of milliseconds can not be hold on an unsigned long. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 09 Jun 2010 20:35:00 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/4327#comment:2 https://svn.boost.org/trac10/ticket/4327#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">viboes</span> added </li> </ul> Ticket James_E_K@… Thu, 26 Aug 2010 13:32:36 GMT <link>https://svn.boost.org/trac10/ticket/4327#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:3</guid> <description> <p> I got rid of the warning by adding this after the existing pin_to_zero: </p> <blockquote> <p> inline int64_t pin_to_zero(int64_t value) { </p> <blockquote> <p> return (value&lt;0)?0ull:(int64_t)value; </p> </blockquote> <p> } </p> </blockquote> <p> And adding this new interruptable_wait function: </p> <blockquote> <p> inline void interruptible_wait(int64_t milliseconds) { </p> <blockquote> <p> interruptible_wait(detail::win32::invalid_handle_value,milliseconds); </p> </blockquote> <p> } </p> </blockquote> <p> Whether or not this properly works with a value greater than ULONG_MAX is unknown. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>sshock</dc:creator> <pubDate>Thu, 04 Nov 2010 21:17:19 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4327#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:4</guid> <description> <p> I'm running into this too. How can I find out when it will be fixed? </p> </description> <category>Ticket</category> </item> <item> <author>Jamie Kirkpatrick <jkp@…></author> <pubDate>Tue, 30 Nov 2010 18:31:44 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4327#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:5</guid> <description> <p> The fix James_E_K suggested worked for me too....suggest something like this is rolled in as not many teams put up with that kind of warning from their code! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>JFC</dc:creator> <pubDate>Tue, 21 Dec 2010 22:28:08 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4327#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:6</guid> <description> <p> I also have this problem with VS2010 and Boost 1.45 </p> </description> <category>Ticket</category> </item> <item> <dc:creator>wsxedcrfv</dc:creator> <pubDate>Wed, 22 Dec 2010 23:52:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4327#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:7</guid> <description> <p> ok nice fix. but i get this error when i compile: LINK : fatal error LNK1561: Einstiegspunkt muss definiert werden. </p> <p> i put the first function in thread_data.hpp at the and of the namespace detail and the second function at the end of the namespace this_thread. </p> <p> im using visual c++ 2010 express and boost 1.45. </p> <p> what have i done wrong? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 23 Feb 2011 14:51:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4327#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:8</guid> <description> <p> Is it fixed in 1.46? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 10 Mar 2011 00:37:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4327#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:9</guid> <description> <p> Can anyone tell me the best way to work around the issue for a simple call: </p> <p> boost::this_thread::sleep(boost::posix_time::milliseconds(i_Milliseconds)); </p> <p> fails this way: </p> <p> ... : see reference to function template instantiation 'void boost::this_thread::sleep&lt;boost::date_time::subsecond_duration&lt;base_duration, frac_of_second&gt;&gt;(const <a class="missing wiki">TimeDuration</a> &amp;)' being compiled 1&gt; with 1&gt; [ 1&gt; base_duration=boost::posix_time::time_duration, 1&gt; frac_of_second=0x03e8, 1&gt; <a class="missing wiki">TimeDuration</a>=boost::date_time::subsecond_duration&lt;boost::posix_time::time_duration,0x03e8&gt; 1&gt; ] ... thread_data.hpp(172): warning C4244: 'argument' : conversion from '<span class="underline">int64' to 'long', possible loss of data </span></p> <p> Thanks! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Thu, 10 Mar 2011 15:41:11 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4327#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:10</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/4327#comment:8" title="Comment 8">anonymous</a>: </p> <blockquote class="citation"> <p> Is it fixed in 1.46? </p> </blockquote> <p> no </p> </description> <category>Ticket</category> </item> <item> <author>Pavel Machyniak <machyniak@…></author> <pubDate>Thu, 10 Mar 2011 17:47:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4327#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:11</guid> <description> <p> While it will be fixed, here is workaround: convert to absolute time. </p> <p> Example (boost 1.46): </p> <pre class="wiki">void sleepMillisec( long milliseconds ) { boost::this_thread::sleep( boost::get_system_time() + boost::posix_time::milliseconds( std::max&lt;long&gt;(milliseconds,0) ) ); } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Sun, 08 May 2011 00:30:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4327#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:12</guid> <description> <p> Why hasn't this been fixed yet (as of 1.46.1)? I've had to use the edit James_E_K suggested above since this warning started appearing. It breaks all of my boost::this_thread::sleep code since I treat warnings as errors. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 30 May 2011 16:50:21 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/4327#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/4327#comment:13</guid> <description> <p> when this will be fixed? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Anthony Williams</dc:creator> <pubDate>Tue, 31 May 2011 12:29:15 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/4327#comment:14 https://svn.boost.org/trac10/ticket/4327#comment:14 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Fixed on trunk, revision 72303 </p> Ticket