THRUST_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE bug in clang compilation
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 487
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 296
Description
when compiled with clang, code will go #if part due to __has_feature(...),
diff --git a/thrust/optional.h b/thrust/optional.h
index 8f881ee..d02e017 100644
--- a/thrust/optional.h
+++ b/thrust/optional.h
@@ -116,7 +116,7 @@ THRUST_NAMESPACE_END
#if defined(__GLIBCXX__) && __has_feature(is_trivially_assignable)
#define THRUST_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \
\- __is_trivially_assignable(T, T const&)
\+ __is_trivially_assignable(T&, T const&)
#else
#define THRUST_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(T) \
std::is_trivially_copy_assignable::value
@@ -132,7 +132,7 @@ THRUST_NAMESPACE_END
#if defined(__GLIBCXX__) && __has_feature(is_trivially_assignable)
#define THRUST_OPTIONAL_IS_TRIVIALLY_MOVE_ASSIGNABLE(T) \
\- __is_trivially_assignable(T, T&&)
\+ __is_trivially_assignable(T&, T&&)
#else
#define THRUST_OPTIONAL_IS_TRIVIALLY_MOVE_ASSIGNABLE(T) \
std::is_trivially_move_assignable::value
but "__is_trivially_assignable(T, T const&)" and " __is_trivially_assignable(T, T&&)" are all wrong. and we can add simple change as following and compile.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 967ebf53..8d32b65e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,8 @@ cmake_minimum_required(VERSION 3.15)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
cmake_policy(SET CMP0104 OLD)
endif()
\+SET(CMAKE_C_COMPILER /usr/bin/clang)
\+SET(CMAKE_CXX_COMPILER /usr/bin/clang++)
project(Thrust NONE)
diff --git a/testing/cuda/is_sorted_until.cu b/testing/cuda/is_sorted_until.cu
index 9e6d5ac7..f04b7997 100644
--- a/testing/cuda/is_sorted_until.cu
+++ b/testing/cuda/is_sorted_until.cu
@@ -1,7 +1,7 @@
#include
#include
#include
+#include
#ifdef THRUST_TEST_DEVICE_SIDE
template
@@ -15,6 +15,8 @@ void is_sorted_until_kernel(ExecutionPolicy exec, Iterator1 first, Iterator1 las
template
void TestIsSortedUntilDevice(ExecutionPolicy exec)
{
\+ **static_assert(THRUST_OPTIONAL_IS_TRIVIALLY_COPY_ASSIGNABLE(int));**
\+
size_t n = 1000;
in /usr/include/c++/9/type_traits file, we can find std::is_trivially_copy_assignable, which is derived from "__is_trivially_assignable(_Tp&, const _Tp&)"
/// is_trivially_copy_assignable
template::value>
struct __is_trivially_copy_assignable_impl;
template
struct __is_trivially_copy_assignable_impl<_Tp, false>
: public false_type { };
template
struct __is_trivially_copy_assignable_impl<_Tp, true>
: public __bool_constant<**__is_trivially_assignable(_Tp&, const _Tp&)**>
{ };
template
struct is_trivially_copy_assignable
: public __is_trivially_copy_assignable_impl<_Tp>
{ };
Contributor guide
Assessment
This issue has not been assessed yet.