title: C++ - std::thread crashes upon execution
body: <p>I am using VS2012 and I can't execute a thread in my program without it crashing. It should be noted that my program contains OpenGL and SOIL.</p>
  
  <p>I simply call a blank thread, a function with no statements, in one of my functions and it immediately crashes:</p>
  
  <pre><code>void service(){
  
  }
  
  /* Connect to server */
  void connectToServer(){
  
      cout &lt;&lt; "~CLIENT~\n" &lt;&lt; endl;
  
      std::thread serverConnect(service);
  }
  </code></pre>
  
  <p>When the program calls <code>connectToServer()</code> it breaks at the call statement <code>std::thread serverConnect(service);</code> with the following call-stack:</p>
  
  <pre class="lang-none prettyprint-override"><code>msvcr110.dll!_crt_debugger_hook(int _Reserved) Line 60  C
  msvcr110.dll!_call_reportfault(int nDbgHookCode, unsigned long dwExceptionCode, unsigned long dwExceptionFlags) Line 152    C++
  msvcr110.dll!abort() Line 90    C
  msvcr110.dll!terminate() Line 96    C++
  IRC.exe!connectToServer() Line 449  C++
  IRC.exe!handleKeypress(unsigned char key, int x, int y) Line 936    C++
  glut32.dll!1000e054()   Unknown
  [Frames below may be incorrect and/or missing, no symbols loaded for glut32.dll]    
  glut32.dll!1000d5de()   Unknown
  user32.dll!753962fa()   Unknown
  user32.dll!75396d3a()   Unknown
  user32.dll!75396ce9()   Unknown
  user32.dll!753a0d27()   Unknown
  user32.dll!753a0d4d()   Unknown
  opengl32.dll!18f160fb() Unknown
  user32.dll!753962fa()   Unknown
  user32.dll!75396d3a()   Unknown
  user32.dll!75396ce9()   Unknown
  user32.dll!753977c4()   Unknown
  user32.dll!753bd62a()   Unknown
  user32.dll!75397bca()   Unknown
  glut32.dll!10004970()   Unknown
  glut32.dll!10004a7a()   Unknown
  glut32.dll!1000491f()   Unknown
  IRC.exe!main(int argc, char * * argv) Line 1683 C++
  IRC.exe!__tmainCRTStartup() Line 536    C
  kernel32.dll!7551338a() Unknown
  ntdll.dll!77049f72()    Unknown
  ntdll.dll!77049f45()    Unknown
  </code></pre>
  
  <p>The program works perfectly without the thread call statement. Also, my VS environment has no problem running simple example thread programs like this one:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;thread&gt;
  using namespace std;
  //This function will be called from a thread
  
  void call_from_thread() {
      std::cout &lt;&lt; "Hello, World" &lt;&lt; std::endl;
  }
  
  int main() {
      //Launch a thread
      thread t1(call_from_thread);
  
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>It's only when I use threads in my program that it crashes.</p>