This optimization, as described in PR27658, is safe to perform with Apple pthreads. The implementation of pthread_mutex_destroy does nothing except poison the lock to aid in debugging .
If we choose to apply this patch we'll lose some amount of error checking, but I think it's probably worth it given the codegen improvements for global of function local static mutexes.
This same optimization can safely be applied to ~condition_variable, since the destructor doesn't check the return value of the pthread_cond_destroy call. But it looks like we lose more debuggability with condvar than we do with mutex .
What do you think?