Unary * or & applied to immediately invoked lambda passed to constructor cast parsed as decomposition group (original) (raw)

Since 11.0.0,

int main() { int(*[] { return new int; }()); }

<source>:2:20: warning: ISO C++17 does not allow a decomposition group to be empty [-Wempty-decomposition]
int main() { int(*[] { return new int; }()); }
                   ^
<source>:2:22: error: expected ')'
int main() { int(*[] { return new int; }()); }
                     ^
<source>:2:17: note: to match this '('
int main() { int(*[] { return new int; }()); }
                ^
<source>:2:19: warning: decomposition declarations are a C++17 extension [-Wc++17-extensions]
int main() { int(*[] { return new int; }()); }
                  ^~
<source>:2:19: error: decomposition declaration cannot be declared with type 'int (*)'; declared type must be 'auto' or reference to 'auto'
<source>:2:19: error: decomposition declaration '[]' requires an initializer

And, similarly,

struct S { S(...); void f(); }; int main() { S(& -> int& { return *new int; }()).f(); }

<source>:2:20: error: expected unqualified-id
int main() { S(&[]() -> int& { return *new int; }()).f(); }
                   ^
<source>:2:22: error: expected ')'
int main() { S(&[]() -> int& { return *new int; }()).f(); }
                     ^
<source>:2:15: note: to match this '('
int main() { S(&[]() -> int& { return *new int; }()).f(); }
              ^

Possibly related to #35570 ?