public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "artur77 at freemail dot hu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/103664] New: std::regex_replace bug if the string contains \0
Date: Sat, 11 Dec 2021 21:52:15 +0000	[thread overview]
Message-ID: <bug-103664-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 103664
           Summary: std::regex_replace bug if the string contains \0
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: artur77 at freemail dot hu
  Target Milestone: ---

I think I found a bug in std::regex_replace.

The following code should write "1a b2" with length 5, but it writes "1a2" with
length 3.


#include <iostream>
#include <regex>

using namespace std;
int main()
{
    string a = regex_replace("1<sn>2", std::regex("<sn>"), string("a\0b", 3));

    cout << "a: " << a << "\n";
    cout << a.length();

    return 0;
}

             reply	other threads:[~2021-12-11 21:52 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-11 21:52 artur77 at freemail dot hu [this message]
2021-12-12  2:39 ` [Bug libstdc++/103664] " pinskia at gcc dot gnu.org
2021-12-12 12:26 ` redi at gcc dot gnu.org
2021-12-12 12:34 ` redi at gcc dot gnu.org
2021-12-13 11:16 ` cvs-commit at gcc dot gnu.org
2021-12-13 11:50 ` redi at gcc dot gnu.org
2022-07-07 23:32 ` cvs-commit at gcc dot gnu.org
2023-06-09  9:47 ` redi at gcc dot gnu.org
2023-06-23 16:12 ` cvs-commit at gcc dot gnu.org
2023-06-23 16:18 ` 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-103664-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).