title: Is leaking std::thread undefined behaviour?
body: <p>Reason why somebody would be interested in </p>
  
  <pre><code>  //...
   new std::thread (func,arg1,arg2);
  
  }
  </code></pre>
  
  <p>is that <code>std::thread</code> destructor(unlike <code>boost::thread</code>) kills the thread. func finishes is some time.
  My question is this safe in cases:</p>
  
  <p>Case 1: lets say that function takes arg1, arg2 by value.<br>
  Case 2: lets say that function takes arg1, arg2 by reference-this sounds bad if you ask me, because I presume that at the end of the scope where thread is created arg1 and arg2 will be cleared by their destructors.</p>
  
  <p>BTW is std::thread destructor(that is AFAIK called when func finishes) smart enough to clear all the resources used by thread? I mean if I create 1M threads(ofc not at the same time) with new and all of them finish, have I leaked anything permanently? </p>