Opened 6 years ago

Closed 5 years ago

#12473 closed Bugs (fixed)

Alternative parser inside permutation parser synthesizes uninitialized optional<>

Reported by: edaskel@… Owned by: Joel de Guzman
Milestone: To Be Determined Component: spirit
Version: Boost 1.61.0 Severity: Problem
Keywords: Cc:

Description

In the process of developing a grammar I discovered a strange behavior where combining alternative and permutation parsers with attributeless parsers can result in invalid optional<> objects. For example, using "eps" as an example of an attributeless parser:

((int_ | eps) ^ eps)

is compatible with optional<int> and compiles successfully, but if you parse an input where the int is not present, an uninitialized optional<> is produced - it acts as though it stored an int, but the value is uninitialized (32766, 32765, or 32764, on my system).

The expression:

(-int_ ^ eps)

also displays this behavior.

I do have a workaround - using only the permutation parser works correctly.

Attachments (1)

optional_issue_reduced.cpp (798 bytes ) - added by edaskel@… 6 years ago.
reduced testcase

Download all attachments as: .zip

Change History (3)

by edaskel@…, 6 years ago

Attachment: optional_issue_reduced.cpp added

reduced testcase

comment:1 by Nikita Kniazev <nok.raven@…>, 5 years ago

comment:2 by Joel de Guzman, 5 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.