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.
Not reproducible neither with gcc 3.4.6 nor 4.1.3 on NetBSD 5.99.17 (-current). Please submit a patch.