<html>
<head>
<base href="https://bugs.llvm.org/">
</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 - regex uses truncated pattern if normal character is escaped"
href="https://bugs.llvm.org/show_bug.cgi?id=44844">44844</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>regex uses truncated pattern if normal character is escaped
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>FreeBSD
</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>mail@maxlor.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>If a pattern in which a normal character is escaped (e.g.: "a\bc"), the LLVM
libc++ only appears to use the part of the pattern up to that character.
Test program:
===== regextest.cpp BEGIN =====
#include <iostream>
#include <regex>
#include <vector>
using namespace std;
int main() {
vector<string> patterns = {
R"(abc)",
R"(a\bc)",
R"(a\bx)",
R"(a\xc)",
R"(x\bc)",
};
for (const string &pattern : patterns) {
cout << pattern << ": ";
try {
regex r(pattern, regex::extended);
bool match = regex_search("abc", r);
cout << (match ? "match" : "no match") << endl;
} catch (const std::regex_error &e) {
cout << "regex error: " << e.what() << endl;
}
}
return 0;
}
===== regextest.cpp END =====
expected output (confirmed on Linux with GCC):
abc: match
a\bc: match
a\bx: no match
a\xc: no match
x\bc: no match
Incorrect output on FreeBSD 12.1 with system c++ compiler/toolchain (LLVM
8.0.1):
abc: match
a\bc: match
a\bx: match
a\xc: match
x\bc: no match
The bug appears on OS X as well.</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>