http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55471
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-11-26 19:24:38 UTC --- Almost certainly what happens is that the mutex m gets destroyed when returning from main, but there are threads still using it and so they can no longer lock it. It's undefined behaviour to lock a mutex after its destructor starts, so this is a bug in your program, not GCC.