[Boost-bugs] [Boost C++ Libraries] #2045: lexical_cast<std::string> of short unsigned produces warnigns with g++ and -Wsign-promo

Subject: [Boost-bugs] [Boost C++ Libraries] #2045: lexical_cast<std::string> of short unsigned produces warnigns with g++ and -Wsign-promo
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-06-24 07:51:16


#2045: lexical_cast<std::string> of short unsigned produces warnigns with g++ and
-Wsign-promo
---------------------------------+------------------------------------------
 Reporter: aeriksson_at_[hidden] | Owner: nasonov
     Type: Bugs | Status: new
Milestone: Boost 1.36.0 | Component: lexical_cast
  Version: Boost 1.35.0 | Severity: Problem
 Keywords: |
---------------------------------+------------------------------------------
 {{{
 #include <boost/lexical_cast.hpp>

 void foo() {
   short unsigned int x;
   boost::lexical_cast<std::string>(x);
 }
 }}}

 Compiled with g++ 4.2.0, boost 1.35.0, and the -Wsign-promo flag this
 produces the following warnings:

 {{{
 /opt/boost/include/boost-1_35/boost/lexical_cast.hpp: In member function
 â€˜bool boost::detail::lexical_stream_limited_src<CharT, Base,
 Traits>::operator<<(short unsigned int) [with CharT = char, Base =
 boost::detail::lexical_streambuf_fake, Traits = std::char_traits<char>]’:
 /opt/boost/include/boost-1_35/boost/lexical_cast.hpp:1146: instantiated
 from ‘Target boost::detail::lexical_cast(typename
 boost::call_traits<Source>::param_type, CharT*, size_t) [with Target =
 std::basic_string<char, std::char_traits<char>, std::allocator<char> >,
 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&) [with Target =
 std::basic_string<char, std::char_traits<char>, std::allocator<char> >,
 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)’
 }}}

--
Ticket URL: <http://svn.boost.org/trac/boost/ticket/2045>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.


This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:58 UTC