Why does the below crash? My pointer is still alive and is constructed in the main so it should not die until main returns :S
I was using this with createthread a while back but my Mingw4.5 never supported it. I just upgraded to 4.7 but now this crashes and if I use it with CreateThread, it does not crash but rather it prints nothing. So I decided to do the following to test why CreateThread did nothing with the pointer but instead I get a bad crash.
void Meh(int X, int Y)
{
std::cout<< X <<" | "<<Y;
}
void Test(LPVOID lpParameter)
{
std::function<void()> func = *((std::function<void()>*)lpParameter);
func();
}
void Run(std::function<void()>* F)
{
Test((void*)&F);
}
int main(int argc, char* argv[])
{
//std::cout.flags(std::ios::boolalpha);
std::function<void()> F = std::bind(Meh, 10, 10);
Run(&F);
return 0;
};