Boost C++ Libraries: Ticket #12333: boost/algorithm/hex.hpp: warning C4244: 'return': conversion from 'unsigned int' to 'unsigned char' https://svn.boost.org/trac10/ticket/12333 <p> … which is not surprise: </p> <pre class="wiki"> template &lt;typename T&gt; unsigned char hex_char_to_int ( T val ) { char c = static_cast&lt;char&gt; ( val ); unsigned retval = 0; // &lt;-- // ... return retval; // &lt;-- } </pre><p> Compiler output: </p> <pre class="wiki">1&gt;boost/algorithm/hex.hpp(74): warning C4244: 'return': conversion from 'unsigned int' to 'unsigned char', possible loss of data 1&gt; boost/algorithm/hex.hpp(129): note: see reference to function template instantiation 'unsigned char boost::algorithm::detail::hex_char_to_int&lt;char&gt;(T)' being compiled 1&gt; with 1&gt; [ 1&gt; T=char 1&gt; ] 1&gt; boost/algorithm/hex.hpp(196): note: see reference to function template instantiation 'unsigned char *boost::algorithm::detail::decode_one&lt;InputIterator,OutputIterator,bool(__cdecl *)(Iterator,Iterator)&gt;(InputIterator &amp;,InputIterator,OutputIterator,EndPred)' being compiled 1&gt; with 1&gt; [ 1&gt; InputIterator=const char *, 1&gt; OutputIterator=unsigned char *, 1&gt; Iterator=const char *, 1&gt; EndPred=bool (__cdecl *)(const char *,const char *) 1&gt; ] </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12333 Trac 1.4.3 Marshall Clow Mon, 18 Jul 2016 18:36:52 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12333#comment:1 https://svn.boost.org/trac10/ticket/12333#comment:1 <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">invalid</span> </li> </ul> <p> We've been down this road before; the compiler is flat out wrong here. </p> <p> This function returns a value in the range 0 .. 255; there is no loss of data. </p> <p> Please report this bug against the MS compiler instead. </p> Ticket pravic <ehysta@…> Mon, 18 Jul 2016 19:23:53 GMT <link>https://svn.boost.org/trac10/ticket/12333#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12333#comment:2</guid> <description> <p> What about <em>compatibility</em>? During many years Boost has been developed to be compatible with lot of compilers (even really old and outdated ones). And now you telling about bug in MSVC? Not very professional answer. </p> </description> <category>Ticket</category> </item> </channel> </rss>