PR libstdc++/81266 fix std:🧵: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.

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

From-SVN: r271080
This commit is contained in:
Jonathan Wakely 2019-05-10 22:41:23 +01:00 committed by Jonathan Wakely
parent 4b7a3ab82f
commit 1a1e427caa
2 changed files with 11 additions and 1 deletions

View File

@ -1,5 +1,9 @@
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.
PR libstdc++/90397
* include/std/variant (_Variant_storage<false, Types...>::_M_storage())
(_Variant_storage<true, Types...>::_M_reset()))

View 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);