llvm-project
llvm-project copied to clipboard
[clang] Structured bindings cannot be initialized from braced rvalue arrays
The following code fails to compile:
struct Array {
int data[2];
};
Array f() { return {}; }
int main() {
auto [a, b]{f().data}; // xvalue init
using T = int [2];
auto [c, d]{T{}}; // prvalue init
}
See Compiler Explorer: https://godbolt.org/z/P3EPzWdTc
@llvm/issue-subscribers-clang-frontend
Author: None (MagentaTreehouse)
The following code fails to compile:
```cpp
struct Array {
int data[2];
};
Array f() { return {}; }
int main() { auto [a, b]{f().data}; // xvalue init using T = int [2]; auto [c, d]{T{}}; // prvalue init }
See Compiler Explorer: https://godbolt.org/z/P3EPzWdTc
</details>
Duplicate of: https://github.com/llvm/llvm-project/issues/31813