Opened 8 years ago

#10102 new Bugs

dynamic_properties inconsistent usage of lexical_cast and stringstream

Reported by: Sergey Mitsyn <svm at jinr.ru> Owned by: Jeremiah Willcock
Milestone: To Be Determined Component: graph
Version: Boost 1.55.0 Severity: Problem
Keywords: Cc:

Description

Hello,

The boost::dynamic_properties is inconsistent with usage of boost::lexical_cast and std::stringstream. In file boost\property_map\dynamic_property_map.hpp, the function

template<typename Value>
  inline Value read_value(const std::string& value)

uses boost::lexical_cast, while

std::string dynamic_property_map_adaptor::get_string(const any& key)

uses std::stringstream.

It is a problem, for example, if used together with a BGL's boost::write_graphvis_dp and boost::read_graphvis if NaN attribute values are written and read. With std::stringstream on my machine (Windows 7 + MSVC 12), NaN's are written as "1.#QNAN", and lexical_cast produces and consumes nan and NAN [1]. In such case boost::bad_lexical_cast is thrown whenever read_graphvis is called for graphviz file containing NaNs.

Modifying dynamic_property_map_adaptor::get_string to use boost::lexical_cast seems to fix the issue with graph reading/writing. Though I'm not trying to use such files as an input for graphviz.

Speaking about graphviz, docs seem not to define any restrictions on attribute values, and I haven't looked at the source code. Quick googling gave me [http:/_/comments.gmane.org/gmane.comp.video.graphviz/7062], which is not related to this case, but it is stated there that graphviz uses atof(), which is locale-dependent and feels messy.

[1] see boost/lexical_cast.hpp, function

template <class CharT, class T>
bool parse_inf_nan(const CharT* begin, const CharT* end, T& value)

Change History (0)

Note: See TracTickets for help on using tickets.