public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "kariya_mitsuru at hotmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/64239] New: regex_iterator::operator= should copy match_results::position Date: Tue, 09 Dec 2014 14:06:00 -0000 [thread overview] Message-ID: <bug-64239-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 Bug ID: 64239 Summary: regex_iterator::operator= should copy match_results::position Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: kariya_mitsuru at hotmail dot com Created attachment 34231 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34231&action=edit g++ -v Please see the following sample. ========================================== sample code ========================================== #include <iostream> #include <regex> #include <string> int main() { std::regex re("\\w+"); std::string s("-a-b-c-"); for (auto it1 = std::sregex_iterator(s.begin(), s.end(), re), end = std::sregex_iterator(); it1 != end; ++it1) { auto it2 = it1; std::cout << "position() = " << it1->position() << ", length() = " << it1->length() << ", str() = '" << it1->str() << "'\n" "position() = " << it2->position() << ", length() = " << it2->length() << ", str() = '" << it2->str() << "'\n\n"; } } ================================================================================================= ============================= output ============================= position() = 1, length() = 1, str() = 'a' position() = 1, length() = 1, str() = 'a' position() = 3, length() = 1, str() = 'b' position() = 1, length() = 1, str() = 'b' position() = 5, length() = 1, str() = 'c' position() = 1, length() = 1, str() = 'c' ================================================================== cf. http://melpon.org/wandbox/permlink/IiULKqL2GwCwwvHc Though the C++11 standard says nothing about regex_iterator::operator=, I think that it2->position() should be equal to it1->position(). So, the output should be ============================= output ============================= position() = 1, length() = 1, str() = 'a' position() = 1, length() = 1, str() = 'a' position() = 3, length() = 1, str() = 'b' position() = 3, length() = 1, str() = 'b' position() = 5, length() = 1, str() = 'c' position() = 5, length() = 1, str() = 'c' ==================================================================
next reply other threads:[~2014-12-09 14:06 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-12-09 14:06 kariya_mitsuru at hotmail dot com [this message] 2014-12-10 13:36 ` [Bug libstdc++/64239] " redi at gcc dot gnu.org 2014-12-10 13:39 ` redi at gcc dot gnu.org 2014-12-10 16:20 ` kariya_mitsuru at hotmail dot com 2014-12-11 6:52 ` timshen at gcc dot gnu.org 2014-12-13 22:19 ` timshen at gcc dot gnu.org 2014-12-13 23:11 ` timshen at gcc dot gnu.org 2015-01-07 3:16 ` kariya_mitsuru at hotmail dot com 2015-01-09 3:59 ` timshen at gcc dot gnu.org 2015-01-09 5:52 ` timshen at gcc dot gnu.org 2015-03-09 6:45 ` timshen at gcc dot gnu.org 2023-07-20 11:42 ` 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-64239-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: linkBe 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).