This fixes an invalid narrowing conversion that causes problems when
libstdc++ is used with clang++ on non-pthreads targets.
PR libstdc++/53578
* include/ext/concurrence.h (__recursive_mutex::_S_destroy): Fix
narrowing conversion.
* include/std/mutex (__recursive_mutex_base::_S_destroy): Likewise.
Tested x86_64-linux with _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
defined so the code is executed. Committed to trunk.
commit 583eb7d9fdcf5365c286fd85c0b43406a9ce46ef
Author: Jonathan Wakely <[email protected]>
Date: Fri Jun 15 01:01:03 2012 +0100
PR libstdc++/53578
* include/ext/concurrence.h (__recursive_mutex::_S_destroy): Fix
narrowing conversion.
* include/std/mutex (__recursive_mutex_base::_S_destroy): Likewise.
diff --git a/libstdc++-v3/include/ext/concurrence.h
b/libstdc++-v3/include/ext/concurrence.h
index 22c433b..25e218b 100644
--- a/libstdc++-v3/include/ext/concurrence.h
+++ b/libstdc++-v3/include/ext/concurrence.h
@@ -284,7 +284,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// matches a gthr-win32.h recursive mutex
template<typename _Rm>
- static typename __enable_if<sizeof(&_Rm::sema), void>::__type
+ static typename __enable_if<(bool)sizeof(&_Rm::sema), void>::__type
_S_destroy(_Rm* __mx)
{
__gthread_mutex_t __tmp;
@@ -293,7 +293,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// matches a recursive mutex with a member 'actual'
template<typename _Rm>
- static typename __enable_if<sizeof(&_Rm::actual), void>::__type
+ static typename __enable_if<(bool)sizeof(&_Rm::actual), void>::__type
_S_destroy(_Rm* __mx)
{ __gthread_mutex_destroy(&__mx->actual); }
diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index a7ebace..34d64c5 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -116,13 +116,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// matches a recursive mutex with a member 'actual'
template<typename _Rm>
- static typename enable_if<sizeof(&_Rm::actual), void>::type
+ static typename enable_if<(bool)sizeof(&_Rm::actual), void>::type
_S_destroy(_Rm* __mx)
{ __gthread_mutex_destroy(&__mx->actual); }
// matches a gthr-win32.h recursive mutex
template<typename _Rm>
- static typename enable_if<sizeof(&_Rm::sema), void>::type
+ static typename enable_if<(bool)sizeof(&_Rm::sema), void>::type
_S_destroy(_Rm* __mx)
{
__gthread_mutex_t __tmp;