Index: src/thread.cpp =================================================================== --- src/thread.cpp +++ src/thread.cpp @@ -46,14 +46,17 @@ void thread::join() { - int ec = __libcpp_thread_join(&__t_); + int ec = EINVAL; + if (__t_ != 0) + { + ec = __libcpp_thread_join(&__t_); + if (ec == 0) + __t_ = 0; + } #ifndef _LIBCPP_NO_EXCEPTIONS if (ec) throw system_error(error_code(ec, system_category()), "thread::join failed"); -#else - (void)ec; #endif // _LIBCPP_NO_EXCEPTIONS - __t_ = 0; } void