Opened 6 years ago
Closed 5 years ago
#12473 closed Bugs (fixed)
Alternative parser inside permutation parser synthesizes uninitialized optional<>
| Reported by: | 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)
Change History (3)
by , 6 years ago
| Attachment: | optional_issue_reduced.cpp added | 
|---|
comment:2 by , 5 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 


reduced testcase