title: What's the default calling convention of a C++ lambda function?
body: <p>The following code was compiled with VC++ 2012:</p>
  
  <pre><code>void f1(void (__stdcall *)())
  {}
  
  void f2(void (__cdecl *)())
  {}
  
  void __cdecl h1()
  {}
  
  void __stdcall h2()
  {}
  
  int main()
  {
      f1(h1); // error C2664
      f2(h2); // error C2664
  
      f1([](){}); // OK
      f2([](){}); // OK
  
      auto fn = [](){};
  
      f1(fn); // OK
      f2(fn); // OK
  }
  </code></pre>
  
  <p>I think the errors are normal yet the OKs are abnormal.</p>
  
  <p>So, my questions are:</p>
  
  <ol>
  <li><p>What's the calling convention of a C++ lambda function?</p></li>
  <li><p>How to specify the calling convention of a C++ lambda function?</p></li>
  <li><p>If the calling convention is not defined, how to correctly recycle the stack space after having called a lambda function?</p></li>
  <li><p>Does the compiler automatically generate multiple versions of a lambda function? i.e. as the following pseudo-code:</p>
  
  <p>[] __stdcall (){};</p>
  
  <p>[] __cdecl (){}; etc.</p></li>
  </ol>