title: boost::asio::yield_context: unexpected forced_unwind exception
body: <p>I'm tring to write my custom async function for boost::asio as described <a href="https://stackoverflow.com/questions/24497881/boostasiospawn-yield-as-callback">here</a>.</p>
  
  <p>However I'm getting boost::coroutines::detail::forced_unwind exception on line with <strong>result.get</strong></p>
  
  <pre><code>#include &lt;boost/chrono.hpp&gt;
  #include &lt;boost/asio.hpp&gt;
  #include &lt;boost/asio/spawn.hpp&gt;
  #include &lt;boost/asio/steady_timer.hpp&gt;
  
  #include &lt;iostream&gt;
  
  namespace asio = ::boost::asio;
  
  
  template &lt;typename Timer, typename Token&gt;
  auto my_timer (Timer&amp; timer, Token&amp;&amp; token)
  {
    typename asio::handler_type&lt;Token,
        void (::boost::system::error_code const)&gt;::type
        handler (std::forward&lt;Token&gt; (token));
  
    asio::async_result&lt;decltype (handler)&gt; result (handler);
  
    timer.async_wait (handler);
    return result.get (); // Got forced_unwind exception here.
  }
  
  int main ()
  {
    asio::io_service io;
    asio::steady_timer timer (io, ::boost::chrono::seconds (1));
  
    asio::spawn (io, [&amp;] (asio::yield_context yield)
        {
        try {
          std::cout &lt;&lt; "my_timer enter\n";
          my_timer (timer, yield);
          std::cout &lt;&lt; "my_timer returns\n";
        }
        catch (const boost::coroutines::detail::forced_unwind&amp; e)
        { 
          std::cout &lt;&lt; "boost::coroutines::detail::forced_unwind\n"; 
        }
      }
    );
  
    io.run ();
  }
  </code></pre>
  
  <p>Same code on <a href="http://coliru.stacked-crooked.com/a/119690d6c24abe00" rel="nofollow noreferrer">Coliru</a></p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>The behavior exists on:</p>
  
  <pre><code>Darwin 14.0.0 (MacOS 10.10) 
  clang version 3.6.0 (trunk 216817) and gcc version 4.9.1 (MacPorts gcc49 4.9.1_1) 
  boost 1.57
  </code></pre>
  
  <p>and</p>
  
  <pre><code>Red Hat 6.5
  gcc version 4.7.2 20121015 (Red Hat 4.7.2-5) (GCC)
  boost 1.57 and 1.56
  (the example code was trivially modified because gcc 4.7 does not support c++14 mode)
  </code></pre>