<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54614>54614</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
C++20 allows to capture structured binding
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
le-migou
</td>
</tr>
</table>
<pre>
Since p1091r3 adoption, capturing structured bindings is allowed. Given this:
```
int main ()
{
int x[2] = { 1, 2 };
auto [ a, b ] = x;
auto f = [=](){ return a; };
}
```
clang 13.0.1 says:
```
clang++ -std=c++2a -Wall -Wextra csb.cpp
csb.cpp:5:28: error: reference to local binding 'a' declared in enclosing function 'main'
auto f = [=](){ return a; };
^
csb.cpp:4:12: note: 'a' declared here
auto [ a, b ] = x;
^
1 error generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylUsmS2yAQ_Rp06bKKRbKsgw72OMkH5JAzlloyKQwqQDOev08j25VklkMqFIhu8ejlPU5-eO2-G9cjzIK3IijQg5-T8Y7JJ-j1nJZg3AQxhaUnGwc4GTfQrwgmgrbWv-BQwjfzjA7S2USm9owfGd-zLb_P1TUuwUUbB0zumGzvmOZwM4BGRlxZfZCsPgJTtJoDiFyHJPPI1B9YvSQPhAWdz0_wuHJ9jxpvseoDbQS7p6fQAakhRxHU4a_42f6og95qYkKokpcCon79tNUVyOSBJmxiGihxf3Olhs0PIo2-eE1BQx9PZT_P93t3R-1rWlSn2gOG4EM2Ao4YMCtFPVnfa_tQghhtiIYGBqTMWSJimZDWx3w6Lq7PgmZYFoC2_2UIPh-s_vK2mYqWkLkH5xPm_V3BZ2rtX8V9m1DcuIIJHQad6FW-EacYOjW0qtVFMsli93TXhN-ecczE3l48fvDeiyXY7pzSvMouv9KcTDov1KW_kGPt82PbzMH_xD6Ra2JcMJJRV1tRFeeO16NoGyqDN6OSI1fjtu21EK3SvMZ2V1h9Qhu7rIaUDl9gDUE2sVCYTnIpuZKtUHwrRan1blfzYSubpqr6oWIVRxLZlrmO0oepCN1a0mmZIh1aE1P8fahjNJNDXNNRfGL-7OkGbi5m8kux5u7W2n8BKsgrRw">