Opened 11 years ago
Last modified 9 years ago
#5658 assigned Tasks
how to get rid of nasty compiler warning in boost/property_tree/detail/rapidxml.hpp
| Reported by: | Owned by: | Sebastian Redl | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | property_tree |
| Version: | Boost 1.46.1 | Severity: | Optimization |
| Keywords: | Cc: | gcc, 4.0, mateusz@… |
Description (last modified by )
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 ---
Change History (3)
comment:1 by , 11 years ago
| Component: | graph → property_tree |
|---|---|
| Owner: | changed from to |
comment:2 by , 9 years ago
| Cc: | added; removed |
|---|---|
| Description: | modified (diff) |
comment:3 by , 9 years ago
| Status: | new → assigned |
|---|
Note:
See TracTickets
for help on using tickets.

Does this still occur since the code was changed to compare against 127?