http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51008
Bug #: 51008 Summary: GTHR - extend interface with __gthread_recursive_mutex_destroy Classification: Unclassified Product: gcc Version: 4.6.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: libstdc++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: andv...@gmail.com This is not a direct libstdc++ bug, but an interface issue of gthreads. I haven't found a similar bug report except for #46455. The issue appears because in libstdc++-v3/include/ext/concurrence.h in d-tor of __recursive_mutex class, when a custom GTHR implementation is used (We have to provide one for a legacy non-POSIX OS). According to SVN, the problem still exists in branch 4.6 and trunk. I can propose two solutions: 1. Add __gthread_recursive_mutex_destroy and get rid of _S_destroy template hacks. 2. Add a new macro __GTHREAD_RECURSIVE_MUTEX_DESTROY_FUNCTION. If the macro is defined by GTHR implementation then __mutex d-tor shall call it instead of _S_destroy hacks. It shall be also a good solution for Win32 and other custom destructors. IMO, the first one is the most correct. The second is suitable to maintain backward compatibility and is the least risky. I can provide a patch for the second approach, if needed.