<html>
<head>
<base href="https://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 --- - wrong comment parsing with regex"
href="https://llvm.org/bugs/show_bug.cgi?id=28998">28998</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>wrong comment parsing with regex
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</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>C++14
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>bremende55@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The compiler misinterprets/ignores the commented out block (see **** lines) and
produces error messages: (C++14 and C++17)
#include <iostream>
#include <regex>
#include <string>
int main() {
std::string astring("// x /* meaningless comment start ");
/* comment results in errors ****
std::string result = std::regex_replace(
astring, std::regex("//[^\n]*/\\*"), "ZZ ");
std::cout << "result = " << result << '\n';
// expected: ZZ meaningless comment start
*/ // end of comment ****
std::cout << "astring = " << astring << '\n';
}
If you delete completely the ****-marked lines, the program compiles and gives
the expected result. clang++ -v gives:
clang version 4.0.0 (trunk 278673)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib64/gcc/x86_64-suse-linux/4.8
Found candidate GCC installation:
/usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/6.1.0
Found candidate GCC installation:
/usr/local/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.0
Selected GCC installation:
/usr/local/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.1.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64</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>