Boost C++ Libraries: Ticket #2045: lexical_cast<std::string> of short unsigned produces warnigns with g++ and -Wsign-promo https://svn.boost.org/trac10/ticket/2045 <pre class="wiki">#include &lt;boost/lexical_cast.hpp&gt; void foo() { short unsigned int x; boost::lexical_cast&lt;std::string&gt;(x); } </pre><p> Compiled with g++ 4.2.0, boost 1.35.0, and the -Wsign-promo flag this produces the following warnings: </p> <pre class="wiki">/opt/boost/include/boost-1_35/boost/lexical_cast.hpp: In member function ‘bool boost::detail::lexical_stream_limited_src&lt;CharT, Base, Traits&gt;::operator&lt;&lt;(short unsigned int) [with CharT = char, Base = boost::detail::lexical_streambuf_fake, Traits = std::char_traits&lt;char&gt;]’: /opt/boost/include/boost-1_35/boost/lexical_cast.hpp:1146: instantiated from ‘Target boost::detail::lexical_cast(typename boost::call_traits&lt;Source&gt;::param_type, CharT*, size_t) [with Target = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, Source = short unsigned int, bool Unlimited = false, CharT = char]’ /opt/boost/include/boost-1_35/boost/lexical_cast.hpp:1170: instantiated from ‘Target boost::lexical_cast(const Source&amp;) [with Target = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, Source = short unsigned int]’ lexicalWarning.cpp:5: instantiated from here /opt/boost/include/boost-1_35/boost/lexical_cast.hpp:910: warning: passing ‘short unsigned int’ chooses ‘int’ over ‘long int’ /opt/boost/include/boost-1_35/boost/lexical_cast.hpp:910: warning: in call to ‘unsigned int boost::detail::lcast_to_unsigned(int)’ </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2045 Trac 1.4.3 nasonov Sat, 12 Sep 2009 22:40:05 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2045#comment:1 https://svn.boost.org/trac10/ticket/2045#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">worksforme</span> </li> </ul> <p> Not reproducible neither with gcc 3.4.6 nor 4.1.3 on NetBSD 5.99.17 (-current) i386. Please submit a patch. </p> Ticket