[Boost-bugs] [Boost C++ Libraries] #2558: Unnecessary conversion warning in lexical_cast

Subject: [Boost-bugs] [Boost C++ Libraries] #2558: Unnecessary conversion warning in lexical_cast
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2008-12-01 23:58:26


#2558: Unnecessary conversion warning in lexical_cast
-------------------------------------------------+--------------------------
 Reporter: Yang Zhang <yanghatespam_at_[hidden]> | Owner: nasonov
     Type: Bugs | Status: new
Milestone: Boost 1.38.0 | Component: lexical_cast
  Version: Boost Development Trunk | Severity: Problem
 Keywords: |
-------------------------------------------------+--------------------------
 When trying to compile the following against r50058 with g++
 -Wconversion:

 {{{
 #include <boost/lexical_cast.hpp>
 #include <string>
 using namespace boost;
 using namespace std;
 int main() {
   lexical_cast<string>(3);
   return 0;
 }
 }}}

 I get:

 {{{
 /home/yang/work/boost/boost/lexical_cast.hpp: In function ‘CharT*
 boost::detail::lcast_put_unsigned(T, CharT*) [with Traits =
 std::char_traits<char>, T = unsigned int, CharT = char]’:
 /home/yang/work/boost/boost/lexical_cast.hpp:848: instantiated from
 â€˜bool boost::detail::lexical_stream_limited_src<CharT, Base,
 Traits>::operator<<(int) [with CharT = char, Base =
 boost::detail::lexical_streambuf_fake, Traits = std::char_traits<char>]’
 /home/yang/work/boost/boost/lexical_cast.hpp:1142: 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 = int, bool Unlimited = false, CharT =
 boost::lexical_cast::char_type]’
 /home/yang/work/boost/boost/lexical_cast.hpp:1166: instantiated from
 â€˜Target boost::lexical_cast(const Source&) [with Target =
 std::basic_string<char, std::char_traits<char>, std::allocator<char> >,
 Source = int]’
 blah.cc:6: instantiated from here
 /home/yang/work/boost/boost/lexical_cast.hpp:510: warning: conversion to
 â€˜char’ from ‘int’ may alter its value
 /home/yang/work/boost/boost/lexical_cast.hpp:848: instantiated from
 â€˜bool boost::detail::lexical_stream_limited_src<CharT, Base,
 Traits>::operator<<(int) [with CharT = char, Base =
 boost::detail::lexical_streambuf_fake, Traits = std::char_traits<char>]’
 /home/yang/work/boost/boost/lexical_cast.hpp:1142: 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 = int, bool Unlimited = false, CharT =
 boost::lexical_cast::char_type]’
 /home/yang/work/boost/boost/lexical_cast.hpp:1166: instantiated from
 â€˜Target boost::lexical_cast(const Source&) [with Target =
 std::basic_string<char, std::char_traits<char>, std::allocator<char> >,
 Source = int]’
 blah.cc:6: instantiated from here
 /home/yang/work/boost/boost/lexical_cast.hpp:512: warning: conversion to
 â€˜char’ from ‘int’ may alter its value
 /home/yang/work/boost/boost/lexical_cast.hpp:536: warning: conversion to
 â€˜char’ from ‘int’ may alter its value
 }}}

 It seems this is because the header is using CHAR_MAX as-is and
 expecting it to be a char.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/2558>
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:59 UTC