[LLVMbugs] [Bug 22061] New: A match_results returns an incorrect sub_match if the sub_match::matched is false
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Dec 30 01:36:23 PST 2014
http://llvm.org/bugs/show_bug.cgi?id=22061
Bug ID: 22061
Summary: A match_results returns an incorrect sub_match if the
sub_match::matched is false
Product: libc++
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: kariya_mitsuru at hotmail.com
CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
Classification: Unclassified
Created attachment 13607
--> http://llvm.org/bugs/attachment.cgi?id=13607&action=edit
clang++ -v
Please see the following sample.
====================================== 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 = [-4479204, -4479204)
2:true, str = 'abc', range = [0, 3)
==================================================================
cf. http://melpon.org/wandbox/permlink/42XecnPeRQGI1tAV
The C++11 standard 28.10[re.results]/p.4 says, "Otherwise matched is false, and
members first and second point to the end of the sequence that was searched."
So, I think that 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)
==================================================================
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141230/07170958/attachment.html>
More information about the llvm-bugs
mailing list