[clang] [Clang] prevent assertion failure by avoiding always-dependent lambdas in constraint-related nested scopes (PR #173776)
Younan Zhang via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 29 00:30:05 PST 2025
================
@@ -282,3 +281,11 @@ static_assert(__is_same_as(int, helper<int>));
} // namespace GH138018
+
+namespace GH172814 {
+auto t() {
+ int x = 0;
+ return [](auto w=[&] { x += w(); }); // expected-error {{lambda expression in default argument cannot capture any entity}} \
+ // expected-error {{expected body of lambda expression}}
----------------
zyn0217 wrote:
Can we test a valid example?
```cpp
auto f() {
int a = 0;
return [](auto w = [&] { return a; }) {};
};
```
https://github.com/llvm/llvm-project/pull/173776
More information about the cfe-commits
mailing list