<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59015>59015</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
templated lambda binding error
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
urnathan
</td>
</tr>
</table>
<pre>
```
struct Pair { int a;};
Pair Foo ();
auto Bar ()
{
auto [b] = Foo (); // b must be a structured binding
return [&] <typename T> (T) { return b; } (1); // lambda must be a template
}
```
AFAICT that's well formed. GCC accepts.
```
~/llvm/trunk/build/bin/clang++ -std=c++20 -c binding.cc
binding.cc:8:40: error: reference to local binding 'b' declared in enclosing function 'Bar'
return [&] <typename T> (T) { return b; } (1);
^
binding.cc:8:45: note: in instantiation of function template specialization 'Bar()::(anonymous class)::operator()<int>' requested here
return [&] <typename T> (T) { return b; } (1);
^
binding.cc:6:9: note: 'b' declared here
auto [b] = Foo ();
^
1 error generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVEuT2yAM_jX4oknGxq_44EMem05vPewfAIwTWgwp4O5sf32FHWeTPnZ66Ew9gLClkfR9ksxt99qSKr2u9EDSrQ9uFAE-MeWA1DtQJgAj-Y7Uh3hONpPyaC0QuiG0uX2fTzYGCzvmFu2sqq82AJOelDtOygOQ_PDoCfB6xAUchtEH4BIYzEmNTnbAlemUOS3OFukkqk10S2g1O96H14s0bJDwTPKnGOEZQ0ygrtY8xkNgUZddw1-jazbwjt2lEORw0SzIBc7henlkb3vcftw_QzizQGjt4UVqDb11g-zWAB_2e2BCyEvw63vGfnJC6idMQetvAwpEbr6g5KPSXZTK4Ck0Qw4ogt3ByocOaRTzK01hJRaW1kLMLu_e8-0Gd5HiAdI56-LFyV46aYQErI22gunFBRJSc9zQSQwaK6AMoKW2Pmr70YigrIlmWHM8_3VFFn9_9ZDy6U-Ay4jTWKwgSsSgjA_MBMWm9G3_BmUpNfiLFIpp9Z09QJw7dRsX3TBjzetgRw9Ij_c3lb1Ix4K9me9xkBB0ZNLJr6P0Aak8I-n_la93SKtwN_ec_dII99m_P9SPOd3iZXMDwkmaSBbOyG-nIpFtVlWbsirSvEi6Nu-avGFJUEHLdilWt4zs0reT62R0uj2HcPFTteJon1Q4j3wt7PA2ZFGsLs5-lgLn9qi8xwLhpWzSrEzObcmzPBMV78umK9OMZlXN8yrvuqag_SaliWZcat9OxaNGvsDkAu9IR6JamlKaZVmV0jSlxTrLirLJWVXWfcFZtSFFKgem9DrmsbbulLh2SomPJ49KrTz-MW5KbDN1MlJO4dA_cn-2rsV-YPjjMckUu51y_wGZC6WB">