[Boost-bugs] [Boost C++ Libraries] #9853: 'argument' : conversion from 'int' to 'char', possible loss of data

Subject: [Boost-bugs] [Boost C++ Libraries] #9853: 'argument' : conversion from 'int' to 'char', possible loss of data
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-04-08 09:32:31


#9853: 'argument' : conversion from 'int' to 'char', possible loss of data
------------------------------+-----------------------------
 Reporter: nn1436401@… | Owner: vladimir_prus
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: program_options
  Version: Boost 1.55.0 | Severity: Problem
 Keywords: |
------------------------------+-----------------------------
 boost_program_options.1.55.0.16\lib\native\src\parsers.cpp(223): warning
 C4242: 'argument' : conversion from 'int' to 'char', possible loss of data

 tolower returns 'int' and not 'char'.
 The cast must be used:

 {{{#!cpp
 result += static_cast<char>(tolower(s[n]));
 }}}

 {{{#!cpp
                 string result;
                 if (s.find(prefix) == 0) {
                     for(string::size_type n = prefix.size(); n < s.size();
 ++n)
                     {
                         // Intel-Win-7.1 does not understand
             // push_back on string.
                         result += tolower(s[n]);
                     }
 }}}

 P.S.
 Also it is better to use boost algorithm tolower on string rather than
 writing it by ourselves.

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