title: Nested lambda expressions are very slow to compile and generate huge object file by Visual C++
body: <p>I find that nested lambda expressions are very slow to compile and generate huge .obj files. For example, on my computer, the following code generates a obj file of size 4766 KB:</p>
  
  <pre><code>int main()
  {
    auto f = []
    {
      auto f = []
      {
        auto f = []
        {
          auto f = []
          {
            auto f = []
            {
            };
          };
        };
      };
    };
  }
  </code></pre>
  
  <p>And the following code (one more nesting level is added) will cause a <a href="http://msdn.microsoft.com/library/8578y171.aspx" rel="nofollow">C1128</a> error.</p>
  
  <pre><code>int main()
  {
    auto f = []
    {
      auto f = []
      {
        auto f = []
        {
          auto f = []
          {
            auto f = []
            {
              auto f = []
              {
              };
            };
          };
        };
      };
    };
  }
  </code></pre>
  
  <p>Also, they are very slow to compile. Is there any explanation for this? I'm using Visual C++ 2013.</p>
  
  <h1>Update</h1>
  
  <p>This seems to be a bug in Visual C++, I've reported it to Microsoft: <a href="https://connect.microsoft.com/VisualStudio/feedback/details/813755/nested-lambdas-in-visual-c-2013-are-very-slow-to-compile-and-generate-huge-object-file" rel="nofollow">https://connect.microsoft.com/VisualStudio/feedback/details/813755/nested-lambdas-in-visual-c-2013-are-very-slow-to-compile-and-generate-huge-object-file</a>.</p>