This program
struct B {
int i;
};
int foo() {
auto [x] = B{1};
[x]() {
x = 2;
}();
return x;
}
is invalid because not-mutable lambda modifies its read-only capture x, and it is properly rejected by GCC and MSVC, but Clang erroneously admits it. Online demo: https://gcc.godbolt.org/z/46o6jad8n
This program
is invalid because not-mutable lambda modifies its read-only capture
x, and it is properly rejected by GCC and MSVC, but Clang erroneously admits it. Online demo: https://gcc.godbolt.org/z/46o6jad8n