Are spirit parsers not meant to be used with auto?
A simple parser works fine when passed to qi::parse() inline, but crashes with segfault if passed via an auto variable:
#include <cstdio>
#include <string>
#include <boost/spirit/include/qi.hpp>
using namespace std;
namespace qi = boost::spirit::qi;
int main()
{
string line = "[z]";
auto bracketed_z = '[' >> +qi::char_('z') >> ']';
auto p = line.cbegin();
printf("%d", qi::parse(p, line.cend(), '[' >> +qi::char_('z') >> ']')); // Works
p = line.cbegin();
printf("%d", qi::parse(p, line.cend(), bracketed_z)); // Crashes
}
Reproes with g++-4.8 and VC13.
Update: an error was fixed in the original code (p was not re-initialized before the second call to parse()).