From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15108 invoked by alias); 14 Dec 2014 10:38:48 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 15077 invoked by uid 48); 14 Dec 2014 10:38:44 -0000 From: "kariya_mitsuru at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/64303] New: The regex_token_iterator's copy constructor creates an incorrect iterator Date: Sun, 14 Dec 2014 10:38:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kariya_mitsuru at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-12/txt/msg01607.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64303 Bug ID: 64303 Summary: The regex_token_iterator's copy constructor creates an incorrect iterator 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 34278 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34278&action=edit g++ -v Please see the following sample. ========================================== sample code ========================================== #include #include #include int main() { const std::string s(" 111 222 "); const std::regex re("\\w+"); std::sregex_token_iterator it1(s.begin(), s.end(), re), it2(it1), end; for (; it1 != end; ++it1) { std::cout << "range = (" << it1->first - s.begin() << ", " << it1->second - s.begin() << "), " "str = '" << it1->str() << '\'' << std::endl; } std::cout << std::endl; for (; it2 != end; ++it2) { std::cout << "range = (" << it2->first - s.begin() << ", " << it2->second - s.begin() << "), " "str = '" << it2->str() << '\'' << std::endl; } } ================================================================================================= ============================= output ============================= range = (2, 5), str = '111' range = (7, 10), str = '222' range = (488, 10), str = '' range = (7, 10), str = '222' ================================================================== cf. http://melpon.org/wandbox/permlink/Dbb2PcGdnNeNon2r Though the C++11 standard says nothing about the regex_token_iterator's copy constructor, I think that *it2 should be equal to *it1. So, the output should be ============================= output ============================= range = (2, 5), str = '111' range = (7, 10), str = '222' range = (2, 5), str = '111' range = (7, 10), str = '222' ================================================================== Note that the operator= is a same result. cf. http://melpon.org/wandbox/permlink/doxdyo4AfiFM6UMK