[Boost-bugs] [Boost C++ Libraries] #5658: how to get rid of nasty compiler warning in boost/property_tree/detail/rapidxml.hpp

Subject: [Boost-bugs] [Boost C++ Libraries] #5658: how to get rid of nasty compiler warning in boost/property_tree/detail/rapidxml.hpp
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-06-29 07:39:26


#5658: how to get rid of nasty compiler warning in
boost/property_tree/detail/rapidxml.hpp
------------------------------------------------------------+---------------
 Reporter: Dieter Stach <Dieter.Stach@…> | Owner: asutton
     Type: Tasks | Status: new
Milestone: To Be Determined | Component: graph
  Version: Boost 1.46.1 | Severity: Optimization
 Keywords: |
------------------------------------------------------------+---------------
 compiling e.g libs/graph/src/graphml.cpp warns ...
 -----
 /boost/property_tree/detail/rapidxml.hpp: In function `size_t
 boost::property_t
 ree::detail::rapidxml::internal::get_index(Ch) [with Ch = char]':
 ./boost/property_tree/detail/rapidxml.hpp:1413: instantiated from
 `static unsi
 gned char
 boost::property_tree::detail::rapidxml::xml_document<Ch>::whitespace_p
 red::test(Ch) [with Ch = char]'
 ./boost/property_tree/detail/rapidxml.hpp:1542: instantiated from
 `static void
  boost::property_tree::detail::rapidxml::xml_document<Ch>::skip(Ch*&)
 [with Stop
 Pred =
 boost::property_tree::detail::rapidxml::xml_document<char>::whitespace_pr
 ed, int Flags = 3072, Ch = char]'
 ./boost/property_tree/detail/rapidxml.hpp:1377: instantiated from `void
 boost:
 :property_tree::detail::rapidxml::xml_document<Ch>::parse(Ch*) [with int
 Flags =
  3072, Ch = char]'
 ./boost/property_tree/detail/xml_parser_read_rapidxml.hpp:116:
 instantiated fr
 om `void
 boost::property_tree::xml_parser::read_xml_internal(std::basic_istream<
 typename Ptree::key_type::value_type, std::char_traits<typename
 Ptree::key_type:
 :value_type> >&, Ptree&, int, const std::string&) [with Ptree =
 boost::property_
 tree::basic_ptree<std::string, std::string, std::less<std::string> >]'
 ./boost/property_tree/xml_parser.hpp:52: instantiated from `void
 boost::proper
 ty_tree::xml_parser::read_xml(std::basic_istream<typename
 Ptree::key_type::value
 _type, std::char_traits<typename Ptree::key_type::value_type> >&, Ptree&,
 int) [
 with Ptree = boost::property_tree::ptree]'
 libs/graph/src/graphml.cpp:49: instantiated from here
 ./boost/property_tree/detail/rapidxml.hpp:317: warning: comparison is
 always fal
 se due to limited range of data type
 ---------
 Caused by the template:
 template<class Ch>
         inline size_t get_index(const Ch c)
         {
             // If not ASCII char, its sematic is same as plain 'z'
             if (c > 255)
             {
                 return 'z';
             }
             return c;
         }
 ----------
 How to avoid ?
 Just specify additionally a user defined implementation
 of get_index for the "char" type :

         inline size_t get_index(const char c)
         {
             return c;
         }

         template<class Ch>
         inline size_t get_index(const Ch c)
         {
             // If not ASCII char, its sematic is same as plain 'z'
             if (c > 255)
             {
                 return 'z';
             }
             return c;
         }
 ---------
 I checked the code size (using gcc4.0) : same
 and the difference of the ASM code: "same"


 14972c14972
 < cmpq (%r15), %rdi
 ---
> cmpq %rdi, (%r15)
 14974c14974
 < jae .L3637
 ---
> jbe .L3637
 15002c15002
 < cmpq -16(%rsi), %rdi
 ---
> cmpq %rdi, -16(%rsi)
 15004c15004
 < jae .L3643
 ---
> jbe .L3643
 15017c15017
 < cmpq -16(%rdx), %rdi
 ---
> cmpq %rdi, -16(%rdx)
 15019c15019
 < jb .L3796
 ---
> ja .L3796
 15487c15487
 ---

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