<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61786>61786</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Inconsistent spacing when passing C array by const reference
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-format
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
carlosgalvezp
</td>
</tr>
</table>
<pre>
Hi!
We are bumping clang-format from:
`15_15~%2b%2b20220316052642%2b11a12544b5fd-1~exp1~20220316172739.191`
to:
`17_17~%2b%2b20230328053227%2b498e1506981f-1~exp1~20230328173331.583`
And the following example code gets inconsistent spacing when passing C arrays by const reference:
```cpp
#include <cstddef>
template <typename T, std::size_t n>
void foo(T const (&array)[n]);
template <typename T>
struct Foo
{};
template <typename T, std::size_t n>
struct Foo<T const [n]>
{
static constexpr void foo (T const (&array)[n]);
};
```
Running clang-format with default settings leads to:
```cpp
#include <cstddef>
template <typename T, std::size_t n> void foo(T const (&array)[n]);
template <typename T> struct Foo {};
template <typename T, std::size_t n>
struct Foo<T const [n]> { static constexpr void foo(T const(&array)[n]); };
```
Note the inconsistency between the free-standing function, and the member function:
```
void foo(T const (&array)[n]);
void foo(T const(&array)[n]);
```
This does not happen if I apply this change:
```cpp
-struct Foo<T const [n]>
+struct Foo<T [n]>
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VU1v4zYQ_TX0ZWCDH6Y-Djrko0b30kMRoMeAkkYSC4oUxFES7yG_vZAsx95uN5stsAsYtEE-vpnH55kxMdrWIxZM3zJ9vzETdWEsKjO6EFvjnvDzsClDfSx-t0wKxu8ZvzmtfyGYEaGc-sH6FipnfLttwtgbgmYMPVMrkCVc6EehX5nUslwWyaXkSiRcy2Qvly0hjJB6vy91U2_FK74M4vUME6lMVb4TuWAJP5FS-II_fRTpl_yKK5lxraRMl619nqHQPMkz0VzxLzCRKqXETmfqjf-03vgaqENognPheZaJL6YfHEIVaoQWKYL1VfDRRkJPEAdTzbDnDj0M8-v6Fu7AjKM5RiiPMGMJRmxwRF_hRcRZyulTDcO6I5X1lZtqBKbuqkh1jQ1Tv13fIuwHZ2hB0HFAb3qEBybvIFI9R1A30X7GRwL_dvMp2BqaEJjMHtakmMyYTJZUmcyZvvVM38-_1O0Hop2JI41TRXAIYb2U3rL0_mMc72Z8Razu3nJes3x7kHSNAwAQyZCtTkh8GUY4i4YfUn2d_dmfazF_Tt5_VQHPljqosTGTI4hIZH0bwaGpI1z_d3-Z7fATHIeLJ_CrfJ4DfdvZi7h3tMF3Lf0jEC6Ff1Xc1RFKpGdEf2oJI-I2kvH17H0z-Yps8LM0szaNHvsSx8vRNzz___X4Q6LfUfvQ2Qh1wAg-EHRmGNCDbeATmGFwR6D5vOqMb7_fr7YfK1N5-y_cV4gz86YuVJ2r3GywEEnGeZrpvdp0RSKbtMlUmqa6TGSTSYE8lyJJNK8TXjYbW6z9PeeZzLnaYVlhk-m9UGhqXRq259gb63bOPfW7MLYbG-OERSLSLNk4U6KLy2CU8rq2mZTzqByL-dq2nNrI9tzZSPFCRJYcFp8-Ohr-YzJsptEVHdEQ5zeXByYPraVuKndV6Jk8zKHWr-0whr-xIiYPi4DI5GHR8E8AAAD__9lZTn8">