<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/145391>145391</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format: AlignConsecutiveBitFields doesn't work with bit field length specified by template argument
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mathcounts4
</td>
</tr>
</table>
<pre>
clang-format version 19.1.7
`_clang-format:`
```
BasedOnStyle: LLVM
AlignConsecutiveBitFields: AcrossEmptyLinesAndComments
```
`myfile.hpp`:
```
template <int Bits>
struct ABC {
std::size_t fAName : Bits;
std::size_t fB : 1;
std::size_t fCOtherName : 63 - Bits;
};
```
Output:
```
>clang-format myfile.hpp
template <int Bits> struct ABC {
std::size_t fAName : Bits;
std::size_t fB : 1;
std::size_t fCOtherName : 63 - Bits;
};
```
In the output, the `:` and `Bits` on `fAName` are not vertically aligned with the `:` and bit field lengths on `fB` and `fCOtherName`.
Workaround: change `fAName : Bits;` to `fAName : 0 + Bits;`, which `clang-format` then aligns properly.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUlFGPozYQxz-NeRktMnaA5YEHyG2kStvuQ6X28eTAAO4ZG9nDrtJPX5mkd0m6u-pFSMng__wzP489KgQ9WsSa5S3LvyRqpcn5elY0dW61FHbJ0fWnujPKjg-D87MieEUftLOQVWmWlow38Sn412sRk_HVeeHy8KZVAfsX-zudDDLZwPPzH78y3jRGj3bvbMBuJf2KraaDRtOHqGk670J4mhc6PWuLobH93s0zWgp37udwPg3aYDotS3wrmzsR4bwYRQhM7rUlaDUFJp8YbwL5tSNo2j2wsmW8AQAI1EcP2QT9N34lGJrf1ByTm0vmh8J2E2WfKPYvNKHf_GATFxIermxZ-eXy4xbyZaVlpf-iMfl006arnfiQG96h_p_M7xB__1yjf8b9E9S_WKAJwZ3hxX6LLi0uOCjbx2jzKTg4G6Nz5duyR7BuO7qkO2XMCVQ8ddjDm6bpHbOjJhjiKQSDdqQp_OvZXv3dFQsreHqu9E_nvynvVhu5oZuUHfFHNTf7WHAgd7fGgYn2ShFZ3ybdTVF3c8Vi9oT2TBJg8W5Bb05p0teyr2SlEqyzMuclz3dZlkx1Xz1iNuTD4yB4WR4L0cmiUEVWDKIbhpInuhZc5LwQMqu4lFk6DLzKH0VVDSj5Y5mzHcdZaZMa8zqnzo-JDmHFOtvlssoSo45owjZMhLipVYg4Xnwd8x6O6xjYjhsdKPxwIk0G67shAh8OB-gdBstESfDm_LdzH--7BmHBTg8aezie4PslUH5c4whJVm_qiWiJo4aJAxOHUdO0HtPOzUwcYm2Xr4fFu7-wIyYOG3Jg4nChfq3FPwEAAP__i8GZCA">