]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR libstdc++/81266 fix std::thread::native_handle_type test
authorJonathan Wakely <jwakely@redhat.com>
Sat, 11 May 2019 11:35:59 +0000 (12:35 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Sat, 11 May 2019 11:35:59 +0000 (12:35 +0100)
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<native_handle_type> 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.

Backport from mainline
2019-05-10  Jonathan Wakely  <jwakely@redhat.com>

PR libstdc++/81266
* testsuite/util/thread/all.h: Do not use remove_pointer for
std::thread::native_handle_type.

From-SVN: r271094

libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/util/thread/all.h

index 4ac03895bcae0ab49193771d06f2f1df33a3ecb9..a65836f0b669ee3d1a483e866ddfa9af35cb24e6 100644 (file)
@@ -1,3 +1,12 @@
+2019-05-11  Jonathan Wakely  <jwakely@redhat.com>
+
+       Backport from mainline
+       2019-05-10  Jonathan Wakely  <jwakely@redhat.com>
+
+       PR libstdc++/81266
+       * testsuite/util/thread/all.h: Do not use remove_pointer for
+       std::thread::native_handle_type.
+
 2019-05-10  Jonathan Wakely  <jwakely@redhat.com>
 
        PR libstdc++/90397
index e5794fa4a975d5bf0f3f0b5ac41e8bf0ffa3cad7..2aacae4f2fc4ad680dee5f1ae0b7563b95cadb88 100644 (file)
@@ -25,6 +25,7 @@
 #include <sstream>
 #include <stdexcept>
 #include <type_traits>
+#include <thread>
 
 // 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<native_handle>::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<test_type, std::thread>::value,
+       native_handle,
+       typename std::remove_pointer<native_handle>::type>::type native_type;
 
       int st = sizeof(test_type);
       int snt = sizeof(native_type);