undefined behaviour somewhere in boost::spirit::qi::phrase_parse

You cannot use auto to store parser expressions¹

Either you need to evaluate from the temporary expression directly, or you need to assign to a rule/grammar:

const qi::rule<std::string::const_iterator, qi::space_type> doubles_parser_local = qi::double_ >> *(',' >> qi::double_);

You can have your cake and eat it too on most recent BOost versions (possibly the dev branch) there should be a BOOST_SPIRIT_AUTO macro

This is becoming a bit of a FAQ item:

¹ I believe this is actually a limitation of the underlying Proto library. There’s a Proto-0x lib version on github (by Eric Niebler) that promises to solve these issues by being completely redesigned to be aware of references. I think this required some c++11 features that Boost Proto currently cannot use.

Leave a Comment