<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64134>64134</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-format] version 17 trips up on templated base class uniform initialization.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
joeatodd
</td>
</tr>
</table>
<pre>
Running `clang-format test.cpp` (i.e. default style rules) with version 17 on the following reproducer:
``` c++
template <int Dim>
struct Base{};
template <int Dim>
struct Derived : public Base<Dim>{
Derived() : Base<Dim>{} {
// Derived ctor impl
}
};
```
produces:
``` c++
template <int Dim> struct Base {};
template <int Dim> struct Derived : public Base<Dim> {
Derived() : Base<Dim> {}
{
// Derived ctor impl
}
};
```
but it ought to produce:
``` c++
template <int Dim> struct Base {};
template <int Dim> struct Derived : public Base<Dim> {
Derived() : Base<Dim>{} {
// Derived ctor impl
}
};
```
Version 16 produces this correct output.
I played around with this reproducer a little. I think its the combination of the `<Dim>` template argument and the `{}` uniform initialization of the derived class which is confusing `clang-format`. Removing the former or replacing the latter with `()` produces expected output.
Both the versions mentioned here are from the downstream DPC++ project:
Working: `clang-format version 17.0.0 (https://github.com/intel/llvm.git 21ca00fb1cc5408b2428e3c386aa5137ed551fdb)`
Broken: `clang-format version 16.0.0 (https://github.com/intel/llvm.git 751acf357ed192a2f9de5171ccdf4a69510cff37)`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzclU1v4zYQhn8NfRlEoKgv6-DDOq6BvRV7aM8UObK4oUiBHCVNf31ByXKcNljs9uNSQLAhkjN830fDoYzRXBzigVVHVp12cqbBh8NXj5K81rvO69fDl9k54y7Aaq6sdJeH3odREhBGytQ0sZoDE3uTYQYaezlbgkivFiHMFiMTLbwYGuAZQzTeQd6Ad0ADQu-t9S8pd8ApeD0rDKz4xPiJ8e235usDioljepZhwnGykhBY8Wgcwc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