http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60521
Bug ID: 60521 Summary: std::lock_guard ignores adopt_lock strategy Product: gcc Version: 4.8.3 Status: UNCONFIRMED Severity: blocker Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: turchanov at farpost dot com lock_guard created with constructor lock_guard::lock_guard(mutex_type& m, adopt_lock_t tag) must adopt already locked mutex. But current implementation ignores completely this fact and tries to lock passed mutex unconditionally: template<typename _Mutex> class lock_guard { ... lock_guard(mutex_type& __m, adopt_lock_t) : _M_device(__m) { } // calling thread owns mutex ... }; and given the fact that mutex type is not a recursive mutex this code sequence produces a dead-lock: mutex mtx; mtx.lock(); lock_guard<mutex> guard(mtx, adopt_lock); // <-- deadlocks!