Boost C++ Libraries: Ticket #2757: Warning C4244: conversion from 'int' to 'unsigned short' in microsec_time_clock.hpp line 103 https://svn.boost.org/trac10/ticket/2757 <p> With Visual Studio 2005, the compiler raises the following warning: </p> <pre class="wiki">c:\programme\boost\boost_1_38_0\boost\date_time\microsec_time_clock.hpp(103) : warning C4244: 'argument' : conversion from 'int' to 'unsigned short', possible loss of data </pre><p> The members of the std::tm struct are ints, but the greg_year type is declared as unsigned short in greg_year.hpp. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2757 Trac 1.4.3 james@… Fri, 13 Feb 2009 09:25:25 GMT <link>https://svn.boost.org/trac10/ticket/2757#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2757#comment:1</guid> <description> <p> Line 99ff: </p> <div class="wiki-code"><div class="code"><pre><span class="p">...</span> <span class="n">std</span><span class="o">::</span><span class="n">tm</span> <span class="n">curr</span><span class="p">;</span> <span class="n">std</span><span class="o">::</span><span class="n">tm</span><span class="o">*</span> <span class="n">curr_ptr</span> <span class="o">=</span> <span class="n">converter</span><span class="p">(</span><span class="o">&amp;</span><span class="n">t</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">curr</span><span class="p">);</span> <span class="n">date_type</span> <span class="nf">d</span><span class="p">(</span><span class="n">static_cast</span><span class="o">&lt;</span><span class="n">date_type</span><span class="o">::</span><span class="n">year_type</span><span class="o">::</span><span class="n">value_type</span><span class="o">&gt;</span><span class="p">(</span><span class="n">curr_ptr</span><span class="o">-&gt;</span><span class="n">tm_year</span> <span class="o">+</span> <span class="mi">1900</span><span class="p">),</span> <span class="n">static_cast</span><span class="o">&lt;</span><span class="n">date_type</span><span class="o">::</span><span class="n">month_type</span><span class="o">::</span><span class="n">value_type</span><span class="o">&gt;</span><span class="p">(</span><span class="n">curr_ptr</span><span class="o">-&gt;</span><span class="n">tm_mon</span> <span class="o">+</span> <span class="mi">1</span><span class="p">),</span> <span class="n">static_cast</span><span class="o">&lt;</span><span class="n">date_type</span><span class="o">::</span><span class="n">day_type</span><span class="o">::</span><span class="n">value_type</span><span class="o">&gt;</span><span class="p">(</span><span class="n">curr_ptr</span><span class="o">-&gt;</span><span class="n">tm_mday</span><span class="p">));</span> <span class="p">...</span> </pre></div></div><p> This will suppress this warning. </p> </description> <category>Ticket</category> </item> <item> <author>gareth.sylvester-bradley@…</author> <pubDate>Thu, 26 Nov 2009 10:58:21 GMT</pubDate> <title>type changed https://svn.boost.org/trac10/ticket/2757#comment:2 https://svn.boost.org/trac10/ticket/2757#comment:2 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Patches</span> </li> </ul> <p> FWIW, this problem still applies to current release (1.41.0) and trunk. The file &lt;boost/date_time/microsec_time_clock.hpp&gt; ends up included in a lot of situations, e.g. via Boost.Thread, so I see this warning many many many times in my code base. </p> <p> I independently reinvented the same patch as the OP. Unfortunately I didn't think to check Trac until I had one - any chance of this being applied so nobody else has to..? </p> Ticket james@… Thu, 08 Apr 2010 12:32:47 GMT version, milestone changed https://svn.boost.org/trac10/ticket/2757#comment:3 https://svn.boost.org/trac10/ticket/2757#comment:3 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.38.0</span> → <span class="trac-field-new">Boost Development Trunk</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.39.0</span> → <span class="trac-field-new">Boost 1.43.0</span> </li> </ul> <p> Please fix this... The warnings are annoying. </p> Ticket Andrey Semashev Thu, 15 Apr 2010 15:24:00 GMT <link>https://svn.boost.org/trac10/ticket/2757#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2757#comment:4</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/61293" title="Refs #2757. Added explicit casts to avoid warnings on MSVC.">[61293]</a>) Refs <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2757" title="#2757: Patches: Warning C4244: conversion from 'int' to 'unsigned short' in ... (closed: fixed)">#2757</a>. Added explicit casts to avoid warnings on MSVC. </p> </description> <category>Ticket</category> </item> <item> <author>gareth.sylvester-bradley@…</author> <pubDate>Thu, 15 Apr 2010 18:24:22 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2757#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2757#comment:5</guid> <description> <p> Thank you Andrey! </p> <p> I assume this will have to wait for merge until 1.44.0? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Fri, 16 Apr 2010 02:45:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2757#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2757#comment:6</guid> <description> <p> Yes, the problem is not that critical to push it for 1.43. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Mon, 10 May 2010 09:15:49 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/2757#comment:7 https://svn.boost.org/trac10/ticket/2757#comment:7 <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> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/61892" title="Fixes #2757. Added explicit casts to avoid warnings on MSVC.">[61892]</a>) Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/2757" title="#2757: Patches: Warning C4244: conversion from 'int' to 'unsigned short' in ... (closed: fixed)">#2757</a>. Added explicit casts to avoid warnings on MSVC. </p> Ticket michael.cowperthwaite@… Mon, 14 May 2012 17:30:38 GMT <link>https://svn.boost.org/trac10/ticket/2757#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2757#comment:8</guid> <description> <p> Seeing this warning with Boost 1.49, MSVS 2008. The warnings are not suppressible using MS's <code>#pragma warning</code> feature. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Wed, 23 May 2012 17:54:35 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/2757#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/2757#comment:9</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/2757#comment:8" title="Comment 8">michael.cowperthwaite@…</a>: </p> <blockquote class="citation"> <p> Seeing this warning with Boost 1.49, MSVS 2008. The warnings are not suppressible using MS's <code>#pragma warning</code> feature. </p> </blockquote> <p> Sorry, I was wrong; warning at different location. See new ticket <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6936" title="#6936: Bugs: Warning 4244 in posix_time_zone.hpp (closed: worksforme)">#6936</a>. </p> </description> <category>Ticket</category> </item> </channel> </rss>