https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115581
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Barnabás Pőcze from comment #3) > Isn't your testcase a bit different? I guess my question is, why does gcc > feel the need to make a local copy of a by-value argument when calling a > function with a reference to it, but seemingly only in a function generated > from a lambda? No my testcase is exactly what is done when converting a lambda to a function pointer. That is it creates a function which then calls the lamdba. Just like this: ``` struct thing { int x[64]; }; void f10(thing x) { auto l = [](thing x) { g(x); }; l(x); } auto *f13 = f10; ``` Which has still has the extra copy even for clang. That is why I mentioned that clang seems to have a front-end optimization which removes the copy when converting the lambda to a function pointer.