https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84726
Bug ID: 84726 Summary: [8 regression] Unnecessary lambda capture of constant variables Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: ABI Severity: normal Priority: P3 Component: c++ Assignee: jason at gcc dot gnu.org Reporter: jason at gcc dot gnu.org Target Milestone: --- wg21.link/p0588 changes i from not captured to captured by the lambda in this testcase, but an implementation is allowed to optimize away that capture if it doesn't affect the semantics of the program. Since we didn't capture it in previous versions of GCC, the optimization is desirable to avoid an ABI change. int main() { const int i = 42; auto l = [=]{return i;}; if (sizeof(l) > 1) __builtin_abort (); }