[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 Jonathan Wakely changed: What|Removed |Added Target Milestone|--- |4.9.3
[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 Tim Shen timshen at gcc dot gnu.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #10 from Tim Shen timshen at gcc dot gnu.org --- Resolved.
[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 --- Comment #8 from Tim Shen timshen at gcc dot gnu.org --- Author: timshen Date: Fri Jan 9 03:58:59 2015 New Revision: 219373 URL: https://gcc.gnu.org/viewcvs?rev=219373root=gccview=rev Log: PR libstdc++/64239 * include/bits/regex.h (match_results::swap): Use std::swap instead of swap. * include/bits/regex_compiler.tcc (_Compiler::_M_quantifier): Likewise. * testsuite/28_regex/match_results/swap.cc: New testcase. Added: trunk/libstdc++-v3/testsuite/28_regex/match_results/swap.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/regex.h trunk/libstdc++-v3/include/bits/regex_compiler.tcc
[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 --- Comment #9 from Tim Shen timshen at gcc dot gnu.org --- Author: timshen Date: Fri Jan 9 05:52:18 2015 New Revision: 219374 URL: https://gcc.gnu.org/viewcvs?rev=219374root=gccview=rev Log: PR libstdc++/64239 Backported form mainline 2015-01-09 Tim Shen tims...@google.com * include/bits/regex.h (match_results::swap): Use std::swap instead of swap. * include/bits/regex_compiler.tcc (_Compiler::_M_quantifier): Likewise. * testsuite/28_regex/match_results/swap.cc: New testcase. Added: branches/gcc-4_9-branch/libstdc++-v3/testsuite/28_regex/match_results/swap.cc Modified: branches/gcc-4_9-branch/libstdc++-v3/ChangeLog branches/gcc-4_9-branch/libstdc++-v3/include/bits/regex.h branches/gcc-4_9-branch/libstdc++-v3/include/bits/regex_compiler.tcc
[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 --- Comment #7 from Mitsuru Kariya kariya_mitsuru at hotmail dot com --- When I used the match_results::swap on r218710, I got a compilation error. == sample code == #include regex int main() { std::cmatch mm1, mm2; mm1.swap(mm2); } = == g++ output === In file included from /usr/local/gcc-218710/include/c++/5.0.0/regex:59:0, from swap.cpp:1: /usr/local/gcc-218710/include/c++/5.0.0/bits/regex.h: In instantiation of 'void std::match_results template-parameter-1-1, template-parameter-1-2 ::swap(std::match_results template-parameter-1-1, template-parameter-1-2 ) [with _Bi_iter = const char*; _Alloc = std::allocatorstd::sub_matchconst char* ]': swap.cpp:7:15: required from here /usr/local/gcc-218710/include/c++/5.0.0/bits/regex.h:1864:6: error: no matching function for call to 'std::match_resultsconst char*::swap(const char*, const char*)' swap(_M_begin, __that._M_begin); ^ /usr/local/gcc-218710/include/c++/5.0.0/bits/regex.h:1861:7: note: candidate: void std::match_results template-parameter-1-1, template-parameter-1-2 ::swap(std::match_results template-parameter-1-1, template-parameter-1-2 ) [with _Bi_iter = const char*; _Alloc = std::allocatorstd::sub_matchconst char* ] swap(match_results __that) ^ /usr/local/gcc-218710/include/c++/5.0.0/bits/regex.h:1861:7: note: candidate expects 1 argument, 2 provided = g++ -v = Using built-in specs. COLLECT_GCC=/usr/local/gcc-218710/bin/g++ COLLECT_LTO_WRAPPER=/usr/local/gcc-218710/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc.218710/configure --prefix=/usr/local/gcc-218710 --enable-checking=yes --disable-nls --enable-languages=c,c++,lto Thread model: posix gcc version 5.0.0 20141213 (experimental) (GCC) = Note that the sample code above was compiled successfully on r218555. I think that the match_results::swap needs use std::swap; for swapping _M_begin.
[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 --- Comment #5 from Tim Shen timshen at gcc dot gnu.org --- Author: timshen Date: Sat Dec 13 22:19:18 2014 New Revision: 218710 URL: https://gcc.gnu.org/viewcvs?rev=218710root=gccview=rev Log: PR libstdc++/64239 * include/bits/regex.h (match_results::match_results, match_results::operator=, match_results::position, match_results::swap): Remove match_results::_M_in_iterator. Fix ctor/assign/swap. * include/bits/regex.tcc: (__regex_algo_impl, regex_iterator::operator++): Set match_results::_M_begin as start position. * testsuite/28_regex/iterators/regex_iterator/char/ string_position_01.cc: Test cases. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/regex.h trunk/libstdc++-v3/include/bits/regex.tcc trunk/libstdc++-v3/testsuite/28_regex/iterators/regex_iterator/char/string_position_01.cc
[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 --- Comment #6 from Tim Shen timshen at gcc dot gnu.org --- Author: timshen Date: Sat Dec 13 23:10:39 2014 New Revision: 218711 URL: https://gcc.gnu.org/viewcvs?rev=218711root=gccview=rev Log: PR libstdc++/64239 * include/bits/regex.h (match_results::match_results, match_results::operator=, match_results::position, match_results::swap): Fix ctor/assign/swap. * include/bits/regex.tcc: (__regex_algo_impl, regex_iterator::operator++): Set match_results::_M_begin as start position. * testsuite/28_regex/iterators/regex_iterator/char/ string_position_01.cc: Test cases. Modified: branches/gcc-4_9-branch/libstdc++-v3/ChangeLog branches/gcc-4_9-branch/libstdc++-v3/include/bits/regex.h branches/gcc-4_9-branch/libstdc++-v3/include/bits/regex.tcc branches/gcc-4_9-branch/libstdc++-v3/testsuite/28_regex/iterators/regex_iterator/char/string_position_01.cc
[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 Jonathan Wakely redi at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2014-12-10 CC||timshen at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely redi at gcc dot gnu.org --- The problem is that match_results::_M_in_iterator is always false after copy/moving a match_results object. I don't even understand what that member is for or what's name means. Tim?
[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 --- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org --- match_results::swap() fails to handle _M_in_iterator as well.
[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 --- Comment #3 from Mitsuru Kariya kariya_mitsuru at hotmail dot com --- Sorry, I confused the copy ctor with the copy assignment operator. But it seems that both are same results. operator= version : http://melpon.org/wandbox/permlink/ZHzYukOyuluuzpwu I didn't notice, but both the copy ctor and the copy assignment operator of match_results are also same results as Mr. Wakely pointed out above. copy ctor version : http://melpon.org/wandbox/permlink/Z4Z0kr5yTcB0iyEk operator= version : http://melpon.org/wandbox/permlink/tHBSWP3hJpinggzw
[Bug libstdc++/64239] regex_iterator::operator= should copy match_results::position
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64239 --- Comment #4 from Tim Shen timshen at gcc dot gnu.org --- Sorry, I was once thinking that we should always use match_results::prefix().first as the start position of a match. It's true for regex_match and regex_search, but not true for regex_iterator. That's why match_results::_M_begin exists. _M_in_iterator was just a dumb mistake that I can't even understand now, probably for my misunderstanding on the start position of a match. Sorry :( Also, obviously I forgot to update ctor/assign/swap after adding match_results::_M_match. I'm testing the patch that fixes this. Later I'll post it in the mailing list. It removes _M_in_iterator. To backport it to 4.9 branch, _M_in_iterator needs to remain. Thanks for reporting and investigating!