[Bug libstdc++/64441] A match_results returns an incorrect sub_match if the sub_match::matched is false
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64441 Jonathan Wakely changed: What|Removed |Added Target Milestone|--- |5.0
[Bug libstdc++/64441] A match_results returns an incorrect sub_match if the sub_match::matched is false
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64441 --- Comment #4 from Tim Shen timshen at gcc dot gnu.org --- Author: timshen Date: Tue Mar 10 18:41:46 2015 New Revision: 221330 URL: https://gcc.gnu.org/viewcvs?rev=221330root=gccview=rev Log: PR libstdc++/64441 * include/bits/regex.h (match_results::size, match_results::position, match_results::str, match_results::operator[], match_results::prefix, match_results::suffix, match_results::end, match_results::_M_resize, match_results::_M_unmatched_sub, match_results::_M_prefix, match_results::_M_suffix): Remove global __unmatched_sub. Add unmatched submatch as part of match_results. * include/bits/regex.tcc (__regex_algo_impl, regex_replace, regex_iterator::operator++): Adjust to use match_results::_M_prefix. * testsuite/28_regex/match_results/out_of_range_submatches.cc: New testcases. Added: trunk/libstdc++-v3/testsuite/28_regex/match_results/out_of_range_submatches.cc Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/regex.h trunk/libstdc++-v3/include/bits/regex.tcc
[Bug libstdc++/64441] A match_results returns an incorrect sub_match if the sub_match::matched is false
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64441 Tim Shen timshen at gcc dot gnu.org changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #5 from Tim Shen timshen at gcc dot gnu.org --- Fixed.
[Bug libstdc++/64441] A match_results returns an incorrect sub_match if the sub_match::matched is false
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64441 Jonathan Wakely redi at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2015-03-09 Ever confirmed|0 |1
[Bug libstdc++/64441] A match_results returns an incorrect sub_match if the sub_match::matched is false
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64441 Jonathan Wakely redi at gcc dot gnu.org changed: What|Removed |Added CC||kaballo86 at hotmail dot com --- Comment #3 from Jonathan Wakely redi at gcc dot gnu.org --- *** Bug 64781 has been marked as a duplicate of this bug. ***
[Bug libstdc++/64441] A match_results returns an incorrect sub_match if the sub_match::matched is false
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64441 --- Comment #1 from Tim Shen timshen at gcc dot gnu.org --- Author: timshen Date: Wed Dec 31 10:27:41 2014 New Revision: 219121 URL: https://gcc.gnu.org/viewcvs?rev=219121root=gccview=rev Log: PR libstdc++/64441 * include/bits/regex.tcc (__regex_algo_impl): s/auto/auto/. * include/bits/regex_executor.tcc (_Executor::_M_dfs): Likewise. Modified: trunk/libstdc++-v3/ChangeLog trunk/libstdc++-v3/include/bits/regex.tcc trunk/libstdc++-v3/include/bits/regex_executor.tcc
[Bug libstdc++/64441] A match_results returns an incorrect sub_match if the sub_match::matched is false
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64441 --- Comment #2 from Mitsuru Kariya kariya_mitsuru at hotmail dot com --- The rev.219121 seems to satisfy the sample code above, but does not satisfy another sample code like below. == sample code == #include iostream #include regex int main() { const char s[] = abc; const std::regex re((\\d+)|(\\w+)); std::cmatch m; std::regex_search(s, m, re); std::cout std::boolalpha; for (size_t i = 0, n = m.size(); i = n; ++i) { auto sub = m[i]; std::cout i : sub.matched , str = ' sub.str() ', range = [ sub.first - s , sub.second - s ) std::endl; } } = = output = 0:true, str = 'abc', range = [0, 3) 1:false, str = '', range = [3, 3) 2:true, str = 'abc', range = [0, 3) 3:false, str = '', range = [-140735878146800, -140735878146800) == According to the C++11 standard 28.10.4[re.results.acc]/p.8, If n = size() then returns a sub_match object representing an unmatched sub-expression. So, I think that n = 1 and n = 3 should be an identical result, and the output should be = output = 0:true, str = 'abc', range = [0, 3) 1:false, str = '', range = [3, 3) 2:true, str = 'abc', range = [0, 3) 3:false, str = '', range = [3, 3) ==