public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/102667] New: Inconsistent result of std::regex_match
@ 2021-10-09 17:33 fchelnokov at gmail dot com
  2021-10-09 18:41 ` [Bug libstdc++/102667] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: fchelnokov at gmail dot com @ 2021-10-09 17:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102667
           Summary: Inconsistent result of std::regex_match
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

This program:
```
#include <iostream>
#include <string>
#include <regex>
#include <assert.h>

int main()
{
    std::string input("4321");
    std::regex rg("^([0-9])");
    std::smatch sm;

    bool found = std::regex_match(input, sm, rg);

    assert(!sm.size() == sm.empty());

     std::cout << "ready: " << sm.ready() << ", found: " <<
          found << ", size: " << sm.size() << std::endl;


    for (auto it = sm.begin(); it != sm.end(); ++it)
    {
        std::cout << "iterate '" << *it << "'\n";
    }
}
```
prints rather unexpected:
```
ready: 1, found: 0, size: 0
iterate ''
iterate ''
iterate ''
```
So std::smatch contains 3 entries while its size is zero.

Expected result:
```
ready: 1, found: 0, size: 0
```
Demo: https://gcc.godbolt.org/z/Wfh1vaPqq

Related discussion: https://stackoverflow.com/q/66611132/7325599

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-13 19:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-09 17:33 [Bug libstdc++/102667] New: Inconsistent result of std::regex_match fchelnokov at gmail dot com
2021-10-09 18:41 ` [Bug libstdc++/102667] " redi at gcc dot gnu.org
2021-10-11 19:37 ` cvs-commit at gcc dot gnu.org
2021-10-12 10:58 ` cvs-commit at gcc dot gnu.org
2021-10-12 16:27 ` cvs-commit at gcc dot gnu.org
2021-10-13 19:42 ` cvs-commit at gcc dot gnu.org
2021-10-13 19:44 ` redi at gcc dot gnu.org

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).