MinGW 4.9.2 with -std=c++14
struct Test
{
Test()
{
std::cerr << "constructed in " << std::this_thread::get_id() << "\n";
}
~Test()
{
std::cerr << "destroyed in " << std::this_thread::get_id() << "\n";
}
void call()
{
std::cerr << "called in " << std::this_thread::get_id() << "\n";
}
};
void testFunc(std::unique_ptr<Test> test)
{
test->call();
}
int main(int argc, char* argv[])
{
std::thread thread(testFunc, std::make_unique<Test>());
thread.detach();
// ...
}
Compiles fine and has the expected output:
constructed in 1
called in 2
destroyed in 2
The project I quickly injected it in relies on some C++14 stuff and I was too lazy to work around that but there was really nothing much in C++14 which would change semantics so fundamentally. Considering my past bad experiences with MSVC and standard (non-)compliance, I'm going to blame MSVC here unless someone can dig mitigating circumstances out of the standard.