<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96275>96275</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Cannot capture structured bindings in lambda
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
diehard2
</td>
</tr>
</table>
<pre>
I know they're not allowed in openmp sections from the numerous closed reports on here. However, my case is slightly different. I am not using the structured bindings in openmp yet I'm still getting the error message if I use the openmp flag. Am I not allowed to use structured bindings anywhere in a program that uses openmp? Is there any workaround (short of not using structured bindings)?
```
#include <iostream>
#include <string>
#include <variant>
#include <map>
using test = std::variant<int, double> ;
int main() {
std::map<std::string, test> foo;
foo["test"] = 1;
for (auto& [name, data_holder] : foo) {
std::visit(
[&](auto&& data) {
std::cout << name << std::endl;
}, data_holder);
}
}
```
```
<source>:15:30: error: capturing a structured binding is not yet supported in OpenMP
15 | std::cout << name << std::endl;
| ^
<source>:12:19: note: 'name' declared here
12 | for (auto& [name, data_holder] : foo) {
| ^
```
I see this in Clang 17 and 18
Reproducer here - https://godbolt.org/z/71rnxreKv
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVd2O6jYQfprhZrQo2AmBi1ywYVFRVbXqC1ROPCTucezIP0vp01cOOcBB7E11olVi73i--b75McJ71RmiCop3KPYLEUNvXSUV9cJJtmisvFRH_GbsGUNPF2ClIzQ2oNDankmiMmhHMsOIntqgrPF4cnZIp9HEgZyNHlttPUl0NFoXPFqDPTla4i_2TJ_kgNU4XLAVnlB59Fp1fdAXlOp0IkcmLPGIYpjiRq9MN6H74GIboiOJjTJSmc4_sLlQwCOwckAflNbYUQjfPck563Ag70VHqE54xOhpMs3eJy26Je4GPP4gNtjp4KvIwlzOSVSiIHB0tnMiZUEkyuRnYOAHPPoUyVFywbN134Sz0UgEtvG9dQHt6UHpi1jAtsAPkO0h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