<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/151669>151669</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] Inconsistent handling of local variable capture in default member initializers
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Xniao
</td>
</tr>
</table>
<pre>
Clang inconsistently handles invalid C++ code that captures local variables in default member initializers of local anonymous structs, depending on aggregate initialization syntax.
Clang accepts following code. However, when changing the `s = {}` to `s`, Clang rejects it correctly.
Repro: https://godbolt.org/z/7Gzcn58ns
**Note: When using `--std=c++11`, Clang rejects both cases.**
## Program
```cpp
int main() {
int a = 1;
struct {
int value = a;
} s = {}; // Clang accepts this case
// } s; // Clang rejects this case
return 0;
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEU0GPszYQ_TXDZbSRMYEkBw7JRml7qape2utgBnDl2JE9ZJv99ZUh2293VanIEtIw7_m9GR6lZEfP3EJ9gvpc0CxTiO2f3lIoutA_2ldHfkTrTfDJJmEv7oET-d5xQuvv5GyPr6BPoE9oQs8oEwkauskcOaELhhzeKVrqVgj2PNDsBK987Tii9VYsOfvOMWEYngjywT-uYU6YJM5GEuhX7PnGvrd-xOCRxjHySMI_GEhs8JgeXujvDajjKp6M4ZskHIJz4S2js84N_hze-M4xE79N7NFM5Mf8WSZGaFRCqM4IuxPsztAolLBUoVEZsnJH_ouNJLSCJsTIRtwj3_w732KA6oiTyC1BdQR9AX0ZQ98FJ5sQR9CXd9CX3U_vxtd7n0Ad89H5_BqEM_iPLGtOWRM06uUlSQ_V2azTLsv_VNIFmdBQ4rRZyT6IK9AV_hbDGOmaC41aj7ndQB2tF7yS9aD3oA-La3VEzGVa5lBCtZTWdeC_HWvPndzMSx89-xB2Z_wywuqE6xTw615ksmlRvMhcGp7oDFmfL8APq5-BiJFljh7Ven--8JPJom-r_lAdqOC23NVbVTVVpYqpreueDoNpdMNmr5Rq1JaGute1qoeD6bvCtlrpWu1VqfblvlabsqkO225L_W7oa94OsFV8Jes2zt2vebOFTWnmtqzLpjkUjjp2aQmY1ibrB61z1mKbAS_dPCbYKmeTpB8UYsUtqVwcQ33GXz5FcA3gkoPhW8I-kvc_QSvm6Npv_6aVae42JlxBX7KQ5-vlFkOeN-jLYiyBvjy93Vv9TwAAAP__netV0A">