[clang] [Clang] prevent crash in delayed default-argument lambda captures (PR #176749)
Oleksandr Tarasiuk via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 27 04:46:58 PDT 2026
================
@@ -417,6 +417,15 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
Actions,
Sema::ExpressionEvaluationContext::PotentiallyEvaluatedIfUsed, Param);
+ // Delayed default arguments may contain lambdas, e.g.
+ // struct S {
+ // void ICE(int x, int = sizeof([x] { return x; }()));
+ // }
+ // Lambda capture handling in tryCaptureVariable() expects an enclosing
+ // function scope in Sema's FunctionScopes stack.
+ Sema::FunctionScopeRAII PopFnContext(Actions);
+ Actions.PushFunctionScope();
----------------
a-tarasyuk wrote:
@AaronBallman Thanks. I’ve moved it outside the loop.
https://github.com/llvm/llvm-project/pull/176749
More information about the cfe-commits
mailing list