Boost logo

Boost Users :

Subject: Re: [Boost-users] Newbie Question
From: Jookia (166291_at_[hidden])
Date: 2013-01-11 20:31:10


On 12/01/13 09:46, Walker.Kyle wrote:
> It appears the following code has a warning detected by GCC4.7.2:
>
> /boost/include/boost-1_52/boost/property_tree/detail/ptree_utils.hpp:
> *In instantiation of 'std::string
> boost::property_tree::detail::narrow(const Ch*) [with Ch = wchar_t;
> std::string = std::basic_string<char, std::char_traits<char>,
> std::allocator<char> >]':*
>
> /boost/include/boost-1_52/boost/property_tree/string_path.hpp:64:36:
> required from here
>
> /boost/include/boost-1_52/boost/property_tree/detail/ptree_utils.hpp:76:13:
> warning: comparison between signed and unsigned integer expressions
> [-Wsign-compare]
>
> *boost-1_52\boost\property_tree\detail\ptree_utils.hpp (Starting line 70):*
>
> template<class Ch>
>
> std::string narrow(const Ch *text)
>
> {
>
> std::string result;
>
> while (*text)
>
> {
>
> if (*text < 0 || *text > (std::numeric_limits<char>::max)())
>
> *Shouldn’t it be:*
>
> template<class Ch>
>
> std::string narrow(const Ch *text)
>
> {
>
> std::string result;
>
> while (*text)
>
> {
>
> if (*text < 0 || *text > (std::numeric_limits<Ch>::max)())
>
> Code to reproduce this warning (just the include):
>
> *#include*<boost/property_tree/ptree.hpp>

Hello!

I don't think so. It's casting to a character, which would fail if it's
outside the limits of char.

Cheers,
Jookia.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net