<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 - Non-deterministic formatting of preprocessor directives combined with clang-format comments."
href="https://bugs.llvm.org/show_bug.cgi?id=48710">48710</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Non-deterministic formatting of preprocessor directives combined with clang-format comments.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>11.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</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>Formatter
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nitrix@nitrix.me
</td>
</tr>
<tr>
<th>CC</th>
<td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Hello,
The following code:
==================== example.c ====================
void foo(void) {
// clang-format off
#define BAR 42
// clang-format on
}
===================================================
with the following configuration:
================== .clang-format ==================
---
IndentCaseLabels: 'true'
IndentWidth: '4'
...
===================================================
has non-deterministic behavior. When formatted, the line #2 of example.c with
the `// clang-format off` comments looses its indentation, then, when
formatting is performed again on that output, will re-add the indentation,
effectively toggling back-and-forth.
This is a problem because it constantly generates changes in version-control
for the files affected.
I don't know if the problem is more broad than this, but this is how I was able
to reproduce it.</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>