A GCC bug in C++23 recursive lambdas on Codeforces
Difference between en1 and en2, changed 0 character(s)
I ran into a compiler bug when submitting with the `C++23 (GCC 14-64, msys2)` option on Codeforces.↵
↵
- [Accepted submission](https://codeforces.me/contest/1628/submission/398239845)↵
- [Compilation error](https://codeforces.me/contest/1628/submission/398240402)↵
↵
The compilation error occurs in a recursive lambda inside a member function. In `[&](this auto&& dfs, ...)`, `dfs` refers to the lambda itself, while `this` inside the lambda body refers to the enclosing object. Both `info[u]` and `this->pull(u)` are valid C++23. The affected GCC version mishandles the `this` capture and rejects both expressions. This is a known [GCC bug (PR 113563)](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113563).↵
↵
If you want to use this style on Codeforces, my accepted submission shows a small workaround. Capture the pointer explicitly as `[&, t = this]`, then write `t->info[u]` and `t->pull(u)`. I hope Codeforces can update the C++23 compiler to a version that includes the fix soon.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Nanako7_ix 2026-11-12 19:06:45 0 (published)
en1 English Nanako7_ix 2026-11-12 18:54:46 1038 Initial revision (saved to drafts)