<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - A match_results returns an incorrect sub_match if the sub_match::matched is false"
href="http://llvm.org/bugs/show_bug.cgi?id=22061">22061</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>A match_results returns an incorrect sub_match if the sub_match::matched is false
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kariya_mitsuru@hotmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=13607" name="attach_13607" title="clang++ -v">attachment 13607</a> <a href="attachment.cgi?id=13607&action=edit" title="clang++ -v">[details]</a></span>
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. <a href="http://melpon.org/wandbox/permlink/42XecnPeRQGI1tAV">http://melpon.org/wandbox/permlink/42XecnPeRQGI1tAV</a>
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)
==================================================================</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>