From 1a1e427caae53ffa42d0f192b3d75045e3637539 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 10 May 2019 22:41:23 +0100 Subject: [PATCH] PR libstdc++/81266 fix std::thread::native_handle_type test The test uses remove_pointer because in most cases native_handle_type is a pointer to the actual type that the C++ class contains. However, for std::thread, native_handle_type is the same type as the type contained in std::thread, and so remove_pointer is not needed. On targets where pthread_t is a pointer type remove_pointer is not a no-op, instead it transforms pthread_t and causes the test to fail. The fix is to not apply remove_pointer when testing std::thread. PR libstdc++/81266 * testsuite/util/thread/all.h: Do not use remove_pointer for std::thread::native_handle_type. From-SVN: r271080 --- libstdc++-v3/ChangeLog | 4 ++++ libstdc++-v3/testsuite/util/thread/all.h | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1cc29702bd2..ee7bcdc24a5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,9 @@ 2019-05-10 Jonathan Wakely + PR libstdc++/81266 + * testsuite/util/thread/all.h: Do not use remove_pointer for + std::thread::native_handle_type. + PR libstdc++/90397 * include/std/variant (_Variant_storage::_M_storage()) (_Variant_storage::_M_reset())) diff --git a/libstdc++-v3/testsuite/util/thread/all.h b/libstdc++-v3/testsuite/util/thread/all.h index e5794fa4a97..2aacae4f2fc 100644 --- a/libstdc++-v3/testsuite/util/thread/all.h +++ b/libstdc++-v3/testsuite/util/thread/all.h @@ -25,6 +25,7 @@ #include #include #include +#include // C++11 only. namespace __gnu_test @@ -39,7 +40,12 @@ namespace __gnu_test // Remove possible pointer type. typedef typename test_type::native_handle_type native_handle; - typedef typename std::remove_pointer::type native_type; + // For std::thread native_handle_type is the type of its data member, + // for other types it's a pointer to the type of the data member. + typedef typename std::conditional< + std::is_same::value, + native_handle, + typename std::remove_pointer::type>::type native_type; int st = sizeof(test_type); int snt = sizeof(native_type); -- 2.30.2