https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61909
--- Comment #2 from lukeocamden at gmail dot com --- (In reply to Jonathan Wakely from comment #1) > This is by design. I don't really follow - do you mean a consequence of the design, or does the standard mandate copying/moving the object into the heap, or does using the heap have some other benefit? > I have a patch to do the optimization a bit more aggressively, but still > only for trivially copyable types and others known to be location invariant > (which should include lambdas) That would be a great start - thanks very much!