[all-commits] [llvm/llvm-project] e2c012: [Clang][Sema] Fix crash on lambda parameter pack w...

Akash Agrawal via All-commits all-commits at lists.llvm.org
Tue Jul 21 02:45:57 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e2c012fa55eb16d74f890209dfdd97b0dfd96b15
      https://github.com/llvm/llvm-project/commit/e2c012fa55eb16d74f890209dfdd97b0dfd96b15
  Author: Akash Agrawal <akashag at qti.qualcomm.com>
  Date:   2026-07-21 (Tue, 21 Jul 2026)

  Changed paths:
    M clang/docs/ReleaseNotes.md
    M clang/lib/Sema/SemaDeclCXX.cpp
    M clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p3.cpp

  Log Message:
  -----------
  [Clang][Sema] Fix crash on lambda parameter pack with illegal default argument (#210718)

`Sema::ActOnParamDefaultArgument` checked a default-argument expression
for unexpanded parameter packs before checking whether the parameter
itself is a pack. For a lambda parameter pack given a default argument
that is a pack expansion referencing an enclosing function's parameter
pack (e.g. `[](Types... = args...) {}`), the first check runs while
still inside the lambda's scope and sets
`LambdaScopeInfo::ContainsUnexpandedParameterPack` (a mechanism meant
for legitimate outer-pack references). The subsequent
`isParameterPack()` check then correctly diagnoses the real error and
discards the default argument, but the stale flag survives into the
built `LambdaExpr`'s dependence bits. A later unexpanded-pack check on
that `LambdaExpr` finds nothing to report and hits
`assert(!Unexpanded.empty() || LambdaReferencingOuterPacks)`, aborting
instead of just diagnosing the error.

Fix: check `Param->isParameterPack()` first and return immediately after
discarding the default argument, before ever calling
`DiagnoseUnexpandedParameterPack` on an expression that is about to be
thrown away. [dcl.fct.default]p3 forbids a default argument on a pack
parameter unconditionally, so this ordering is also semantically
correct, not just a crash workaround.

Fixes #210714



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list