public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/64239] New: regex_iterator::operator= should copy match_results::position
@ 2014-12-09 14:06 kariya_mitsuru at hotmail dot com
  2014-12-10 13:36 ` [Bug libstdc++/64239] " redi at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: kariya_mitsuru at hotmail dot com @ 2014-12-09 14:06 UTC (permalink / raw)
  To: gcc-bugs

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'

==================================================================


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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-09 14:06 [Bug libstdc++/64239] New: regex_iterator::operator= should copy match_results::position kariya_mitsuru at hotmail dot com
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

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