title: C++ 11 future_status::deferred not working
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;future&gt;
  #include &lt;chrono&gt;
  
  using namespace std;
  using namespace std::chrono;
  
  int sampleFunction(int a)
  {
      return a;
  }
  
  int main()
  {
     future&lt;int&gt; f1=async(launch::deferred,sampleFunction,10);
     future_status statusF1=f1.wait_for(seconds(10));
     if(statusF1==future_status::ready)
          cout&lt;&lt;"Future is ready"&lt;&lt;endl;
     else if (statusF1==future_status::timeout)
          cout&lt;&lt;"Timeout occurred"&lt;&lt;endl;
     else if (statusF1==future_status::deferred)
          cout&lt;&lt;"Task is deferred"&lt;&lt;endl;
     cout&lt;&lt;"Value : "&lt;&lt;f1.get()&lt;&lt;endl;
  }
  
  Output -
  Timeout occurred
  Value : 10
  </code></pre>
  
  <p>In above example, I was expecting <code>future_status</code> to be <code>deferred</code> instead of <code>timeout</code>. <code>sampleFunction</code> has been launched as <code>launch::deferred</code>. Hence it will not be executed until <code>f1.get()</code> has been called. In such condition <code>wait_for</code> should have returned <code>future_status::deferred</code> and not <code>future_status::timeout</code>. </p>
  
  <p>Appreciate if someone can help me understand this.
  I am using g++ version 4.7.0 on fedora 17.</p>