https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64144
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Oops, that test is always going to deadlock, I meant this: #include <future> std::future<void> fut; struct A { ~A() { fut.wait_for(std::chrono::milliseconds(1)); } }; thread_local A a; void f() { (void)&a; } int main() { fut = std::async(std::launch::async, f); } With this version the thread local destructor detects the state is ready and so tries to join itself, which hangs (although it should throw an exception). The async thread should use the equivalent of set_value_at_thread_exit to delay making the state ready, so that the wait_for() times out instead of trying to join.