Original Post
Are there some obscure rules regarding exceptions and threads that I don't know about? The program crashes when I throw the logic error. Any insight would be appreciated.
#include "windows.h"
#include <iostream>
#include <stdexcept>
void foo(void)
{
throw std::logic_error("Why does this line crash?!");
}
DWORD WINAPI threadEntryPoint(LPVOID)
{
try
{
Sleep(500); // Kill some time. . .
foo();
}
catch(const std::exception &error)
{}
return 0;
}
int main()
{
HANDLE thread[4];
DWORD id[4];
for(int i=0; i<4; ++i)
thread=CreateThread(0, 0, &threadEntryPoint, 0, 0, id+i);
WaitForMultipleObjects(4, thread, TRUE, INFINITE);
std::cout << "Done!" << std::endl;
std::cin.get();
return 0;
}