Is it ok to do the following?
#include <iostream>
#include <thread>
std::thread th;
void foo()
{
std::cout << __func__ << std::endl;
th = std::thread(foo);
}
int main()
{
th = std::thread(foo);
th.join();
}
gcc crashes -- http://coliru.stacked-crooked.com/a/3c926507ab0f8a5c.
I know that there's almost no need to do this but I want to know the answer just for academic purposes.