#include <iostream> #include <thread> class A { public: void operator()() const { std::cout << 'A' << '\n'; } }; int main() { std::thread t(A{}); t.detach(); }
As can be seen here the code compiles and prints 'A' in VS2013, but the code doesn't compile in clang and gcc. If I process the code in clang incoliru, it compiles, but doesn't print 'A'. What's happening here?
Edit: I should have said above, "but the code doesn't compile in clang and emits a run-time error in gcc", instead of "but the code doesn't compile in clang and gcc".