https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102272
Bug ID: 102272 Summary: rejects-valid: VLA captured in generic lambda Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: simon.giesecke at snowflake dot com Target Milestone: --- gcc rejects the following code: ``` int bar(); void foo() { char data[bar()]; [&](auto *ptr) { data; }; } ``` saying: ``` <source>: In function 'void foo()': <source>:6:3: error: use of deleted function 'foo()::<lambda(auto:1*)>::~<lambda>()' 6 | [&](auto *ptr) { data; }; | ^~~~~~~~~~~~~~~~~~~~~~~~ <source>:6:5: note: 'foo()::<lambda(auto:1*)>::~<lambda>()' is implicitly deleted because the default definition would be ill-formed: 6 | [&](auto *ptr) { data; }; | ^ ``` This happens in trunk and in various versions back to 8.x I tried. With a non-generic lambda, this works. Interestingly, it also works if the length of the VLA doesn't depend on the result of a function call, but on a parameter of the function. While this isn't standard C++, gcc supports VLA in C++ code generally, so I think this should also work.