[clang] [Clang][Sema] Fix crash on lambda parameter pack with illegal default argument (PR #210718)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 20 07:06:59 PDT 2026


================
@@ -17,3 +17,13 @@ struct X0 {
 
 template <typename... Ts>
 void defaultpack(Ts... = 0) {} // expected-error{{parameter pack cannot have a default argument}}
+
+// A lambda parameter pack whose default argument is a pack expansion
+// referencing the enclosing function's parameter pack must be diagnosed
+// without crashing.
+template <class... Types> void lambda_pack_default_arg(Types... args) {
+  auto lm = [](Types... = args...) {}; // expected-error{{parameter pack cannot have a default argument}} \
+                                       // expected-warning{{'...' in this location creates a C-style varargs function}} \
+                                       // expected-note{{preceding '...' declares a function parameter pack}} \
+                                       // expected-note{{insert ',' before '...' to silence this warning}}
----------------
cor3ntin wrote:

This warning should not be emitted - can you add a `//FIXME: do not produce these diagnostics` ?

https://github.com/llvm/llvm-project/pull/210718


More information about the cfe-commits mailing list