https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118312
Bug ID: 118312 Summary: Nested lambda with a single return type seems to take too much memory Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: code-size Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rush102333 at gmail dot com Target Milestone: --- Consider the following code: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include<iostream> int main() { const int i = 42; auto l = [=]{ return [&](){ return i+i; }(); }; std::cout<<sizeof(l); } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The output result is 1 under clang, EDG and MSVC. But in gcc it would be 4 no matter '-O1'~'-O3' is involved. I wonder if this needs improving. Please see https://godbolt.org/z/rjxdMvEd5