title: C++11: std::bind crashes with lambda
body: <p>Why does this code crash? </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;functional&gt;
  
  int main(int argc, const char * argv[])
  {
      std::function&lt;void(int)&gt; function = [](int)
      {
      };
      auto binding = std::bind(function, 10);
  
      std::function&lt;void()&gt; jobFunctor = binding; // crashes here with EXC_BAD_ACCESS
  
      return 0;
  }
  </code></pre>
  
  <p>When converting the result of the bind to <code>jobFunctor</code> there is an infinite stack recursion in a <code>std::function</code> constructor.</p>
  
  <p>I am running Mac OS X 10.8.5, I compile this code with Xcode 5.0.2 using libc++, the compiler version: </p>
  
  <pre><code>LO50F-04-198BX:$ clang++ --version
  Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
  Target: x86_64-apple-darwin12.5.0
  Thread model: posix
  </code></pre>