Boost C++ Libraries: Ticket #6444: qi::lit(<char>) parses into a '\0' in 1.47 and 1.48 https://svn.boost.org/trac10/ticket/6444 <p> In 1.46.0, qi::lit(&lt;char&gt;) would end up in the result. This changed in 1.47.0 such that they were not parsed into the result (qi::char_ is to be used instead). However, NUL characters now show up in the resulting token. Example code and output attached. </p> <p> Synopsis: </p> <p> Parser: +(qi::alnum | qi::lit('-')) </p> <p> Input: "a-b-c" </p> <p> 1.46.0: "a-b-c" </p> <p> 1.47.0: "a\000b\000c" </p> <p> 1.48.0: "a\000b\000c" </p> <p> The '\000' characters can be seen in gdb; std::ostream just shows "abc" instead. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6444 Trac 1.4.3 mathstuf@… Tue, 24 Jan 2012 20:16:13 GMT attachment set https://svn.boost.org/trac10/ticket/6444 https://svn.boost.org/trac10/ticket/6444 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">qi.cxx</span> </li> </ul> <p> Small example code </p> Ticket mathstuf@… Tue, 24 Jan 2012 20:17:04 GMT attachment set https://svn.boost.org/trac10/ticket/6444 https://svn.boost.org/trac10/ticket/6444 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">qi-output</span> </li> </ul> <p> Output from 1.46, 1.47, and 1.48 </p> Ticket Joel de Guzman Wed, 25 Jan 2012 00:36:14 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6444#comment:1 https://svn.boost.org/trac10/ticket/6444#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> Use char_ instead (as you hinted): </p> <blockquote> <p> tok %= </p> <blockquote> <p> +( qi::alnum </p> <blockquote> <p> | qi::char_('-') | qi::char_('_') ); </p> </blockquote> </blockquote> </blockquote> <p> lit has an "unused" attribute ( <a class="ext-link" href="http://tinyurl.com/6lu2stx"><span class="icon">​</span>http://tinyurl.com/6lu2stx</a> ) while char gives you the character type of the enclosing character encoding namespace (e.g. ascii, unicode, etc.). The way "unused" attribute is synthesized is undefined. </p> <p> The behavior you see is an upshot of the optimizations and refinement we did for 1.47 and higher. As such, for alternatives, we only synthesize the advertized attribute in cases like this where the client passed in a non-variant (std::string). </p> Ticket mathstuf@… Wed, 25 Jan 2012 00:40:44 GMT <link>https://svn.boost.org/trac10/ticket/6444#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6444#comment:2</guid> <description> <p> Right. That's fine. The bug is that an "unused" attribute should not insert NUL characters in the resulting match. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Joel de Guzman</dc:creator> <pubDate>Wed, 25 Jan 2012 08:50:08 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/6444#comment:3 https://svn.boost.org/trac10/ticket/6444#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">wontfix</span> </li> </ul> <p> Fair enough. Let's open this for discussion then. There might be a "fix", but I'd like to discuss this in the Spirit mailing list. I'll re-open this ticket. Could you please post a message to the list here: <a class="ext-link" href="http://boost-spirit.com/home/feedback-and-support/"><span class="icon">​</span>http://boost-spirit.com/home/feedback-and-support/</a> </p> <p> Thanks! </p> Ticket