https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84726
--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> --- Optimizing it away is allowed by 8.4.5.1p2: An implementation may define the closure type differently from what is described below provided this does not alter the observable behavior of the program other than by changing: — the size and/or alignment of the closure type, — whether the closure type is trivially copyable (Clause 12), or — whether the closure type is a standard-layout class (Clause 12).