<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 - clang-format inserts spurious Carriage Returns in C-style block comment"
href="https://bugs.llvm.org/show_bug.cgi?id=39677">39677</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang-format inserts spurious Carriage Returns in C-style block comment
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</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>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mark.langen@beamdog.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=21126" name="attach_21126" title="Example Code">attachment 21126</a> <a href="attachment.cgi?id=21126&action=edit" title="Example Code">[details]</a></span>
Example Code
**Issue**
When clang-format is run on a C/C++ file with a C-style block comment, if the
block comment contains a non-empty line with only spaces/tabs on it, and the
file uses CRLF line endings, then that line will have a naked Carriage Return
appended to it. Each time clang-format is run on the document an additional
Carriage Return will be added in this way.
**More Details**
The issue seems to occur with any .clang-format settings that I try, and will
never occur with Unix style line endings. Tested with version 6.0.1 and 8.0.0,
issues occurs on both.
**Example**
See attached test.cpp. Run clang-format -i test.cpp on it without a
.clang-format file present.
**Expected behavior**
The line with only 4 spaces on it is cleared (or preserved, I don't know what
the default behavior is supposed to be).
**Observed behavior**
The line with only 4 spaces on it is preserved, and an additional Carriage
Return character is added after the 4 spaces.
**Probable cause**
I'm guessing that there's a `substring(start of line, LF character)` used in
this case that catches the Carriage Return character as part of the line in
files with CRLF line endings.</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>