Opened 11 years ago

Last modified 11 years ago

#6444 reopened Bugs

qi::lit(<char>) parses into a '\0' in 1.47 and 1.48

Reported by: mathstuf@… Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.48.0 Severity: Regression
Keywords: Cc:

Description

In 1.46.0, qi::lit(<char>) 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.

Synopsis:

Parser: +(qi::alnum | qi::lit('-'))

Input: "a-b-c"

1.46.0: "a-b-c"

1.47.0: "a\000b\000c"

1.48.0: "a\000b\000c"

The '\000' characters can be seen in gdb; std::ostream just shows "abc" instead.

Attachments (2)

qi.cxx (1.4 KB ) - added by mathstuf@… 11 years ago.
Small example code
qi-output (447 bytes ) - added by mathstuf@… 11 years ago.
Output from 1.46, 1.47, and 1.48

Download all attachments as: .zip

Change History (5)

by mathstuf@…, 11 years ago

Attachment: qi.cxx added

Small example code

by mathstuf@…, 11 years ago

Attachment: qi-output added

Output from 1.46, 1.47, and 1.48

comment:1 by Joel de Guzman, 11 years ago

Resolution: wontfix
Status: newclosed

Use char_ instead (as you hinted):

tok %=

+( qi::alnum

| qi::char_('-') | qi::char_('_') );

lit has an "unused" attribute ( http://tinyurl.com/6lu2stx ) 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.

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).

comment:2 by mathstuf@…, 11 years ago

Right. That's fine. The bug is that an "unused" attribute should not insert NUL characters in the resulting match.

comment:3 by Joel de Guzman, 11 years ago

Resolution: wontfix
Status: closedreopened

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: http://boost-spirit.com/home/feedback-and-support/

Thanks!

Note: See TracTickets for help on using tickets.