public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/102480] New: std::regex fails to match ^ when match_prev_avail is used
Date: Fri, 24 Sep 2021 23:34:37 +0000	[thread overview]
Message-ID: <bug-102480-4@http.gcc.gnu.org/bugzilla/> (raw)

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	other threads:[~2021-09-24 23:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-24 23:34 redi at gcc dot gnu.org [this message]
2021-09-24 23:34 ` [Bug libstdc++/102480] " redi at gcc dot gnu.org
2021-09-27 11:45 ` redi at gcc dot gnu.org
2021-09-29 12:49 ` cvs-commit at gcc dot gnu.org
2021-09-29 15:47 ` redi at gcc dot gnu.org
2022-07-07 23:32 ` cvs-commit at gcc dot gnu.org
2022-07-07 23:36 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-102480-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).