public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/64303] New: The regex_token_iterator's copy constructor creates an incorrect iterator
@ 2014-12-14 10:38 kariya_mitsuru at hotmail dot com
  2014-12-17  9:26 ` [Bug libstdc++/64303] " timshen at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: kariya_mitsuru at hotmail dot com @ 2014-12-14 10:38 UTC (permalink / raw)
  To: gcc-bugs

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 <iostream>
#include <regex>
#include <string>

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


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

end of thread, other threads:[~2023-07-20 11:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-14 10:38 [Bug libstdc++/64303] New: The regex_token_iterator's copy constructor creates an incorrect iterator kariya_mitsuru at hotmail dot com
2014-12-17  9:26 ` [Bug libstdc++/64303] " timshen at gcc dot gnu.org
2014-12-17 10:27 ` timshen at gcc dot gnu.org
2015-03-09  6:46 ` timshen at gcc dot gnu.org
2023-07-20 11:42 ` 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).