<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121553>121553</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang disallows brace elision in designated initializer of member array when constructing a temporary function parameter
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wangbo15
</td>
</tr>
</table>
<pre>
Clang rejects the following valid code:
```c++
struct B {
int b[10];
};
struct C
{
C (B x) {}
};
//OK
//B bb{.b = 42};
//OK
//C c ({.b = {42}});
//OK
//C c({42});
//Fails
C c ({.b = 42});
```
The question seems to be related to both the designated initializer and the brace elision operation because separately removing the former( like `C c({42});` ) or the latter( like `C c ({.b = {42}});` ) can both make the code compile.
GCC, MSVC, and EDG always accept it.
The diagnostic of clang:
```c++
<source>:17:3: error: no matching constructor for initialization of 'C'
17 | C c ({.b = 42});
| ^ ~~~~~~~~~
<source>:5:8: note: candidate constructor (the implicit copy constructor) not viable: cannot convert initializer list argument to 'const C'
5 | struct C
| ^
<source>:5:8: note: candidate constructor (the implicit move constructor) not viable: cannot convert initializer list argument to 'C'
5 | struct C
| ^
<source>:7:3: note: candidate constructor not viable: cannot convert initializer list argument to 'B'
7 | C (B x) {}
| ^ ~~~
1 error generated.
```
https://godbolt.org/z/eve54hcx3
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVcFu4zYQ_ZrxZbCGRFqWddDBluM9FEUPLXqnqLHELkW6JOWs99BvL0g5ceIk3QK7hgBR9JvBvDePQ-G96g1RDcUOiv1CTGGwrn4Upm9tXixa213qRgvTo6O_SAaPYSA8Wq3tozI9noVWHUrbEfAtQraNzzqbHwlsF59s64ObZMAdQhk_EZUJ2EKxyzMo9sDjJpRPi2d8k7bniAaBbXb4FViVspT7uxhgB2CH3355Xu6wbaHcLVsEvscVu4HvkQ3KmP0GhnI348s9sOrjqDlohr7GHYTS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