<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113537>113537</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] BinPackArguments incorrectly breaks line
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ixSci
</td>
</tr>
</table>
<pre>
Having the following simple code:
```
#include <array>
void foo() {
const int minSpace = 4;
const std::array spaces{11111, minSpace + 2, minSpace + 5, minSpace, minSpace + 7, minSpace * 2, minSpace + 1};
}
```
And a very simple config:
```
---
ColumnLimit: 100
AllowAllArgumentsOnNextLine: false
BinPackArguments: false
```
clang-format produces the following result:
```
#include <array>
void foo() {
const int minSpace = 4;
const std::array
spaces{11111, minSpace + 2, minSpace + 5, minSpace, minSpace + 7, minSpace * 2, minSpace + 1};
}
```
Where the line starting with `spaces` is one character short of violating the column limit. So the full line violated the limit and it broke it into 2 lines: `const...` and `spaces...`. And if we add another `1` into `11111` making it violate the limit again we will finally get the desired behavior:
```
#include <array>
void foo() {
const int minSpace = 4;
const std::array spaces{111111,
minSpace + 2,
minSpace + 5,
minSpace,
minSpace + 7,
minSpace * 2,
minSpace + 1};
}
```
I expected it to be displayed like this with the original line violating the limit but for some reason it didn't. Is it a bug or some misunderstanding on my part?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVU2PqzYU_TXO5ioIDBPCggWZNOqTntpKs-ja2Be4jbEj22Qm_74yJPPSzFTte6tnRYo_jo8P9xyw8J56g1izpx172q_EFAbranp7kbRqrbrUv4ozmR7CgNBZre1rHHkaTxpBWoUsb1i6Z2nDNun1twx5TkbqSSGw_Fk4Jy4s_2VZO1tS0FnL-JbxCli5W-ZBWuMDkAkwknk5CRk376Fg-Q1xhfig4sF5MxODj1DPyl0WG-PPd_v5DviHmaf7mQ-r5cNM8wlDxsr9u6zY_6wIjV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