Clang emits a warning if I use a structured binding declaration as a condition:
$ cat hello.cc
int main() {
struct A { int i; operator bool() { return true; } };
if (auto [i] = A{0}) {
return i;
}
return -1;
}
$ clang++-10 -std=c++17 hello.cc
hello.cc:3:12: warning: ISO C++17 does not permit structured binding declaration in a condition [-Wbinding-in-condition]
if (auto [i] = A{0}) {
^~~
1 warning generated.
I don't see this in dcl.struct.bind or stmt.select; where would I see that this is forbidden?
Furthermore: what is the rationale behind forbidding this?