https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98008
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- If the following C program works, but 54185.cc deadlocks, it suggests there might be a bug in the libstdc++ code or test instead (this C program fails on AIX, due to a bug in pthread_cond_wait). This works OK on darwin. #include <pthread.h> #include <stddef.h> #include <stdlib.h> pthread_cond_t* cv; pthread_mutex_t mx; #define N 10 int n; void* f(void* d) { pthread_mutex_lock(&mx); if (++n == N) { /* unblock all threads */ pthread_cond_broadcast(cv); pthread_cond_destroy(cv); free(cv); cv = NULL; } else /* block */ pthread_cond_wait(cv, &mx); pthread_mutex_unlock(&mx); return d; } int main() { int i; pthread_t th[N]; pthread_mutex_init(&mx, NULL); cv = malloc(sizeof(*cv)); pthread_cond_init(cv, NULL); for (i = 0; i < N; ++i) pthread_create(th+i, NULL, f, NULL); for (i = 0; i < N; ++i) pthread_join(th[i], NULL); pthread_mutex_destroy(&mx); }