[gcc/devel/omp/gcc-9] PR libstdc++/81266 fix std::thread::native_handle_type test
Tobias Burnus
burnus@gcc.gnu.org
Thu Mar 5 13:47:00 GMT 2020
https://gcc.gnu.org/g:a301651022734f4a0f744d4c2ebe8a77f27abf5a
commit a301651022734f4a0f744d4c2ebe8a77f27abf5a
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Sat May 11 12:35:59 2019 +0100
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<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
Diff:
---
libstdc++-v3/ChangeLog | 9 +++++++++
libstdc++-v3/testsuite/util/thread/all.h | 8 +++++++-
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 4ac0389..a65836f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -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
diff --git a/libstdc++-v3/testsuite/util/thread/all.h b/libstdc++-v3/testsuite/util/thread/all.h
index e5794fa..2aacae4 100644
--- a/libstdc++-v3/testsuite/util/thread/all.h
+++ b/libstdc++-v3/testsuite/util/thread/all.h
@@ -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);
More information about the Libstdc++-cvs
mailing list