https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102480

            Bug ID: 102480
           Summary: std::regex fails to match ^ when match_prev_avail is
                    used
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
            Blocks: 102445
  Target Milestone: ---

#include <regex>
#include <cassert>

int main() {
  char str[] = "\na";
  std::regex re("^a");
  assert(std::regex_match(str + 1, str + 2, re));
  using std::regex_constants::match_prev_avail;
  assert(std::regex_match(str + 1, str + 2, re, match_prev_avail));
}

Both assertions should pass.

For the first match, the regex matches at the beginning of the input.

For the second match, the regex should also match because the previous
character is a line terminator.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102445
[Bug 102445] [meta-bug] std::regex issues

Reply via email to