https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64085 --- Comment #1 from Maxim Yegorushkin <maxim.yegorushkin at gmail dot com> --- It compiles fine if I replace the line in question with: return [&captive = static_cast<T&>(arg)](auto&& a) {