Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sequential_or: Fixed random order execution of underlying parsers #310

Merged
merged 1 commit into from
Dec 8, 2017

Commits on Dec 4, 2017

  1. sequential_or: Fixed random order execution of underlying parsers

    After two hours of fighting with the optimizer, I happily drew attention to
    this little nifty bitwise operator in `any_if_ns` function.
    
    Explanation of the bug: bitwise inclusive OR operator is not a sequence point
    (per chapter §5.13 of C++14 standard), that's why at compiling the expression
    `a() | b() | ... | z()` optimizer is allowed to rearrange the execution order
    of the functions `a`, `b` ... `z`.
    
    There is high chance that a lot of people were misguided by the bug and chose
    not to use `sequential_or`.
    
    I vaguely remember how about three years ago I thought that I am dumb and/or
    the documentation is wrong when I tried to use the `sequential_or` but ended
    with some workaround.
    
    There are three possible fixes:
      - This one
      - Make the original `any_ns` and `any_if_ns` strict ordered
        (could potentially make permutations operator slower)
      - Break the `any_ns` and `any_if_ns` API and somehow generalize the code
    Kojoley committed Dec 4, 2017
    Configuration menu
    Copy the full SHA
    6a37fde View commit details
    Browse the repository at this point in the history