[Boost-bugs] [Boost C++ Libraries] #9991: WConversion issue in json_parser_write.hpp

Subject: [Boost-bugs] [Boost C++ Libraries] #9991: WConversion issue in json_parser_write.hpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-05-02 06:21:11


#9991: WConversion issue in json_parser_write.hpp
-------------------------------+------------------------------
 Reporter: abhi.california@… | Type: Bugs
   Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.54.0
 Severity: Problem | Keywords: JSON
-------------------------------+------------------------------
 File Name:
 1_54_0/boost/property_tree/detail/json_parser_write.hpp

 There is a severe problem with the -Wconversion issue in the
 json_parser_write.hpp

 Problematic code:
            else
             {
                 const char *hexdigits = "0123456789ABCDEF";
                 typedef typename make_unsigned<Ch>::type UCh;
                 unsigned long u = (std::min)(static_cast<unsigned long>(
                                                  static_cast<UCh>(*b)),
                                              0xFFFFul);

                ''' int d1 = u / 4096; u -= d1 * 4096;
                 int d2 = u / 256; u -= d2 * 256;
                 int d3 = u / 16; u -= d3 * 16;
                 int d4 = u;'''

                 result += Ch('\\'); result += Ch('u');
                 result += Ch(hexdigits[d1]); result += Ch(hexdigits[d2]);
                 result += Ch(hexdigits[d3]); result += Ch(hexdigits[d4]);
             }

 Either we need to do explicit static cast to suppress the Conversion
 Warning.
 When we turn on the -Wconversion as well as -Werror both together, which
 is good practice for production ready code. compiler Just dont allow this
 to compile.

 the above need to be fixed.

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