diff --git a/.clang-tidy b/.clang-tidy index afea732c2a0..db0c1b1918f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -26,7 +26,6 @@ Checks: - 'modernize-*' - '-modernize-use-integer-sign-comparison' - '-modernize-use-nodiscard' - - '-modernize-use-equals-default' - '-modernize-return-braced-init-list' - '-modernize-use-auto' # END REMOVE ME diff --git a/c/parallel/test/test_radix_sort.cpp b/c/parallel/test/test_radix_sort.cpp index c2e67092003..47a30f05e27 100644 --- a/c/parallel/test/test_radix_sort.cpp +++ b/c/parallel/test/test_radix_sort.cpp @@ -37,7 +37,7 @@ struct TestParameters static constexpr bool m_descending = descending; static constexpr bool m_overwrite_okay = overwrite_okay; - constexpr TestParameters() {} + constexpr TestParameters() = default; bool is_descending() const { diff --git a/c/parallel/test/test_segmented_sort.cpp b/c/parallel/test/test_segmented_sort.cpp index 6c3e29a5071..4ac8a18508f 100644 --- a/c/parallel/test/test_segmented_sort.cpp +++ b/c/parallel/test/test_segmented_sort.cpp @@ -49,7 +49,7 @@ struct TestParameters static constexpr bool m_descending = descending; static constexpr bool m_overwrite_okay = overwrite_okay; - constexpr TestParameters() {} + constexpr TestParameters() = default; constexpr bool is_descending() const { diff --git a/c2h/include/c2h/checked_allocator.cuh b/c2h/include/c2h/checked_allocator.cuh index 9521643acfc..e214a628c24 100644 --- a/c2h/include/c2h/checked_allocator.cuh +++ b/c2h/include/c2h/checked_allocator.cuh @@ -160,7 +160,7 @@ public: using other = checked_cuda_allocator; }; - _CCCL_HOST_DEVICE checked_cuda_allocator() {} + checked_cuda_allocator() = default; _CCCL_HOST_DEVICE checked_cuda_allocator(const checked_cuda_allocator& other) : base(other) @@ -173,7 +173,7 @@ public: checked_cuda_allocator& operator=(const checked_cuda_allocator&) = default; - _CCCL_HOST_DEVICE ~checked_cuda_allocator() {} + ~checked_cuda_allocator() = default; }; struct checked_host_memory_resource final : public THRUST_NS_QUALIFIER::mr::new_delete_resource_base diff --git a/cub/cub/block/block_load_to_shared.cuh b/cub/cub/block/block_load_to_shared.cuh index 9a196e3f652..bae72bb15ac 100644 --- a/cub/cub/block/block_load_to_shared.cuh +++ b/cub/cub/block/block_load_to_shared.cuh @@ -228,7 +228,8 @@ private: class token_impl { friend struct BlockLoadToShared; - _CCCL_DEVICE_API _CCCL_FORCEINLINE token_impl() {} // ctor must have a body to avoid token_impl{} to compile + _CCCL_DEVICE_API _CCCL_FORCEINLINE token_impl() {} // NOLINT(modernize-use-equals-default) ctor must have a body to + // avoid token_impl{} to compile // NOLINTBEGIN(modernize-use-equals-delete) token_impl(const token_impl&) = delete; diff --git a/cub/cub/thread/thread_operators.cuh b/cub/cub/thread/thread_operators.cuh index 65d4c9ab944..60aef44acac 100644 --- a/cub/cub/thread/thread_operators.cuh +++ b/cub/cub/thread/thread_operators.cuh @@ -167,7 +167,7 @@ struct ScanBySegmentOp ScanOpT op; /// Constructor - _CCCL_HOST_DEVICE _CCCL_FORCEINLINE ScanBySegmentOp() {} + _CCCL_FORCEINLINE ScanBySegmentOp() = default; /// Constructor _CCCL_HOST_DEVICE _CCCL_FORCEINLINE ScanBySegmentOp(ScanOpT op) @@ -301,7 +301,7 @@ struct ReduceBySegmentOp ReductionOpT op; /// Constructor - _CCCL_HOST_DEVICE _CCCL_FORCEINLINE ReduceBySegmentOp() {} + _CCCL_FORCEINLINE ReduceBySegmentOp() = default; /// Constructor _CCCL_HOST_DEVICE _CCCL_FORCEINLINE ReduceBySegmentOp(ReductionOpT op) @@ -362,7 +362,7 @@ struct ReduceByKeyOp ReductionOpT op; /// Constructor - _CCCL_HOST_DEVICE _CCCL_FORCEINLINE ReduceByKeyOp() {} + _CCCL_FORCEINLINE ReduceByKeyOp() = default; /// Constructor _CCCL_HOST_DEVICE _CCCL_FORCEINLINE ReduceByKeyOp(ReductionOpT op) diff --git a/cub/cub/util_type.cuh b/cub/cub/util_type.cuh index 324249d5f2f..152409cbe7c 100644 --- a/cub/cub/util_type.cuh +++ b/cub/cub/util_type.cuh @@ -705,7 +705,7 @@ struct KeyValuePair Value value; ///< Item value /// Constructor - _CCCL_HOST_DEVICE _CCCL_FORCEINLINE KeyValuePair() {} + _CCCL_FORCEINLINE KeyValuePair() = default; /// Constructor _CCCL_HOST_DEVICE _CCCL_FORCEINLINE KeyValuePair(Key const& key, Value const& value) diff --git a/cub/test/catch2_test_device_scan_iterators.cu b/cub/test/catch2_test_device_scan_iterators.cu index 4771a2e48d5..1a69cba5212 100644 --- a/cub/test/catch2_test_device_scan_iterators.cu +++ b/cub/test/catch2_test_device_scan_iterators.cu @@ -179,7 +179,7 @@ class custom_accumulator_t {} public: - __host__ __device__ custom_accumulator_t() {} + custom_accumulator_t() = default; __host__ __device__ custom_accumulator_t(const custom_accumulator_t& in) : m_val(in.is_valid() * in.get()) diff --git a/cub/test/catch2_test_device_transform.cu b/cub/test/catch2_test_device_transform.cu index b6098e98f0a..4fd6f36dc50 100644 --- a/cub/test/catch2_test_device_transform.cu +++ b/cub/test/catch2_test_device_transform.cu @@ -521,10 +521,12 @@ struct non_trivial : data(data) {} + // NOLINTNEXTLINE(modernize-use-equals-default) __host__ __device__ non_trivial(const non_trivial& nt) : data(nt.data) {} + // NOLINTNEXTLINE(modernize-use-equals-default) __host__ __device__ auto operator=(const non_trivial& nt) -> non_trivial& { data = nt.data; diff --git a/cudax/test/execution/common/utility.cuh b/cudax/test/execution/common/utility.cuh index 5056fd644c7..282a4873a9f 100644 --- a/cudax/test/execution/common/utility.cuh +++ b/cudax/test/execution/common/utility.cuh @@ -67,13 +67,16 @@ struct potentially_throwing _CCCL_HOST_DEVICE potentially_throwing(potentially_throwing&&) noexcept(false) {} - _CCCL_HOST_DEVICE potentially_throwing(const potentially_throwing&) noexcept(false) {} + _CCCL_HOST_DEVICE + potentially_throwing(const potentially_throwing&) noexcept(false) // NOLINT(modernize-use-equals-default) + {} _CCCL_HOST_DEVICE potentially_throwing& operator=(potentially_throwing&&) noexcept(false) { return *this; } + // NOLINTNEXTLINE(modernize-use-equals-default) _CCCL_HOST_DEVICE potentially_throwing& operator=(const potentially_throwing&) noexcept(false) { return *this; diff --git a/libcudacxx/include/cuda/__stream/launch_transform.h b/libcudacxx/include/cuda/__stream/launch_transform.h index ade537310a4..7771b5cc767 100644 --- a/libcudacxx/include/cuda/__stream/launch_transform.h +++ b/libcudacxx/include/cuda/__stream/launch_transform.h @@ -115,7 +115,9 @@ struct _CCCL_TYPE_VISIBILITY_DEFAULT __launch_transform_t struct __optional_with_a_destructor : ::cuda::std::optional<_Tp> { using ::cuda::std::optional<_Tp>::optional; - ~__optional_with_a_destructor() {} + // Use of explicit destructor is intentional. Without it, the argument may have a trivial + // destructor and hence would be performed by the callee. + ~__optional_with_a_destructor() {} // NOLINT(modernize-use-equals-default) template _CCCL_API inline _CCCL_CONSTEXPR_CXX20 _Tp& __emplace_from_fn(_Fn&& __fn) diff --git a/libcudacxx/include/cuda/std/__optional/optional.h b/libcudacxx/include/cuda/std/__optional/optional.h index b3af41a5426..13bf30c0de8 100644 --- a/libcudacxx/include/cuda/std/__optional/optional.h +++ b/libcudacxx/include/cuda/std/__optional/optional.h @@ -120,7 +120,9 @@ class optional : private __optional_move_assign_base<_Tp> static_assert(!is_array_v, "instantiation of optional with an array type is ill-formed"); public: - _CCCL_API constexpr optional() noexcept {} + // Use of {} vs = default is deliberate. = default may value-initialize, while {} is + // guaranteed to do absolutely nothing. + _CCCL_API constexpr optional() noexcept {} // NOLINT(modernize-use-equals-default) _CCCL_HIDE_FROM_ABI constexpr optional(const optional&) = default; _CCCL_HIDE_FROM_ABI constexpr optional(optional&&) = default; _CCCL_API constexpr optional(nullopt_t) noexcept {} diff --git a/libcudacxx/include/cuda/std/__optional/optional_ref.h b/libcudacxx/include/cuda/std/__optional/optional_ref.h index d941e3102c8..58ad488ce92 100644 --- a/libcudacxx/include/cuda/std/__optional/optional_ref.h +++ b/libcudacxx/include/cuda/std/__optional/optional_ref.h @@ -89,7 +89,9 @@ class optional<_Tp&> public: using value_type = __raw_type&; - _CCCL_API constexpr optional() noexcept {} + // Use of {} vs = default is deliberate. = default may value-initialize, while {} is + // guaranteed to do absolutely nothing. + _CCCL_API constexpr optional() noexcept {} // NOLINT(modernize-use-equals-default) _CCCL_HIDE_FROM_ABI constexpr optional(const optional&) noexcept = default; _CCCL_HIDE_FROM_ABI constexpr optional(optional&&) noexcept = default; _CCCL_API constexpr optional(nullopt_t) noexcept {} diff --git a/libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h b/libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h index 6818b184671..8aece54f00e 100644 --- a/libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h +++ b/libcudacxx/include/cuda/std/__tuple_dir/tuple_leaf.h @@ -105,8 +105,11 @@ class __tuple_leaf<_Ip, _Hp, __tuple_leaf_specialization::__default> #endif // !_CCCL_BUILTIN_REFERENCE_CONSTRUCTS_FROM_TEMPORARY public: + // The compiler-generated constructor would not value-initialize trivial types, but the + // standard requires that we do. _CCCL_EXEC_CHECK_DISABLE - _CCCL_API constexpr __tuple_leaf() noexcept(is_nothrow_default_constructible_v<_Hp>) + _CCCL_API constexpr __tuple_leaf() // NOLINT(modernize-use-equals-default) + noexcept(is_nothrow_default_constructible_v<_Hp>) : __value_() {} @@ -227,14 +230,19 @@ class __tuple_leaf<_Ip, _Hp, __tuple_leaf_specialization::__synthesize_assignmen _CCCL_EXEC_CHECK_DISABLE __tuple_leaf(__tuple_leaf&& __t) = default; + // Do not use = default here. The value type may be a reference, in which case the defaulted + // assignment constructor is implicitly deleted (a quirk in the C++ spec meant). _CCCL_EXEC_CHECK_DISABLE - _CCCL_API constexpr __tuple_leaf& operator=(const __tuple_leaf& __t) noexcept + _CCCL_API constexpr __tuple_leaf& operator=(const __tuple_leaf& __t) noexcept // NOLINT(modernize-use-equals-default) { __value_ = __t.__value_; return *this; } + + // Do not use = default here. The value type may be a reference, in which case the defaulted + // assignment constructor is implicitly deleted (a quirk in the C++ spec meant). _CCCL_EXEC_CHECK_DISABLE - _CCCL_API constexpr __tuple_leaf& operator=(__tuple_leaf&& __t) noexcept + _CCCL_API constexpr __tuple_leaf& operator=(__tuple_leaf&& __t) noexcept // NOLINT(modernize-use-equals-default) { __value_ = ::cuda::std::move(__t.__value_); return *this; @@ -267,8 +275,11 @@ template class __tuple_leaf<_Ip, _Hp, __tuple_leaf_specialization::__empty_non_final> : private remove_const_t<_Hp> { public: + // The compiler-generated constructor would not value-initialize trivial types, but the + // standard requires that we do. _CCCL_EXEC_CHECK_DISABLE - _CCCL_API constexpr __tuple_leaf() noexcept(is_nothrow_default_constructible_v<_Hp>) + _CCCL_API constexpr __tuple_leaf() // NOLINT(modernize-use-equals-default) + noexcept(is_nothrow_default_constructible_v<_Hp>) : _Hp() {} diff --git a/libcudacxx/include/cuda/std/__utility/typeid.h b/libcudacxx/include/cuda/std/__utility/typeid.h index 7e149ba11ee..c16a48327d0 100644 --- a/libcudacxx/include/cuda/std/__utility/typeid.h +++ b/libcudacxx/include/cuda/std/__utility/typeid.h @@ -302,9 +302,7 @@ struct __type_info_ref_ : __type_info : __type_info(__other) {} - _CCCL_API constexpr __type_info_ref_(__type_info_ref_ const& __other) noexcept - : __type_info(__other) - {} + _CCCL_HIDE_FROM_ABI constexpr __type_info_ref_(__type_info_ref_ const& __other) noexcept = default; }; [[nodiscard]] _CCCL_API constexpr __type_info_ref_ __type_info_ptr_::operator*() const noexcept diff --git a/libcudacxx/test/support/test_iterators.h b/libcudacxx/test/support/test_iterators.h index 3df888cd73d..c98aef620f1 100644 --- a/libcudacxx/test/support/test_iterators.h +++ b/libcudacxx/test/support/test_iterators.h @@ -983,13 +983,7 @@ struct NonThrowingIterator , current_(rhs.current_) {} - TEST_FUNC NonThrowingIterator& operator=(const NonThrowingIterator& rhs) noexcept - { - begin_ = rhs.begin_; - end_ = rhs.end_; - current_ = rhs.current_; - return *this; - } + NonThrowingIterator& operator=(const NonThrowingIterator& rhs) noexcept = default; TEST_FUNC reference operator*() const noexcept { @@ -2066,7 +2060,7 @@ class advance_only_iterator using pointer = int*; using reference = int&; - TEST_FUNC constexpr advance_only_iterator() {} + constexpr advance_only_iterator() = default; TEST_FUNC constexpr advance_only_iterator(int* iter) : iter_(iter) {} diff --git a/thrust/benchmarks/bench/copy/basic.cu b/thrust/benchmarks/bench/copy/basic.cu index c285671c63c..7d69d241683 100644 --- a/thrust/benchmarks/bench/copy/basic.cu +++ b/thrust/benchmarks/bench/copy/basic.cu @@ -41,11 +41,13 @@ struct non_trivial {} // the user-defined copy constructor prevents the type from being trivially copyable + // NOLINTNEXTLINE(modernize-use-equals-default) _CCCL_HOST_DEVICE non_trivial(const non_trivial& nt) : a(nt.a) , b(nt.b) {} + // NOLINTNEXTLINE(modernize-use-equals-default) _CCCL_HOST_DEVICE non_trivial& operator=(const non_trivial& nt) { a = nt.a; diff --git a/thrust/benchmarks/bench/uninitialized_copy/basic.cu b/thrust/benchmarks/bench/uninitialized_copy/basic.cu index 62a17f56828..850db5e0087 100644 --- a/thrust/benchmarks/bench/uninitialized_copy/basic.cu +++ b/thrust/benchmarks/bench/uninitialized_copy/basic.cu @@ -37,6 +37,7 @@ struct no_copy {} // the user-defined copy constructor prevents the type from being trivially copyable + // NOLINTNEXTLINE(modernize-use-equals-default) _CCCL_HOST_DEVICE no_copy(const no_copy& nt) : a(nt.a) {} diff --git a/thrust/examples/bounding_box.cu b/thrust/examples/bounding_box.cu index 2d3dc21f636..236a6cfcd0a 100644 --- a/thrust/examples/bounding_box.cu +++ b/thrust/examples/bounding_box.cu @@ -29,7 +29,7 @@ struct point2d struct bbox { // construct an empty box - __host__ __device__ bbox() {} + bbox() = default; // construct a box from a single point __host__ __device__ bbox(const point2d& point) diff --git a/thrust/examples/cuda/range_view.cu b/thrust/examples/cuda/range_view.cu index b7d79ade200..281e2217a59 100644 --- a/thrust/examples/cuda/range_view.cu +++ b/thrust/examples/cuda/range_view.cu @@ -34,7 +34,7 @@ public: : first(first) , last(last) {} - __host__ __device__ ~range_view() {} + ~range_view() = default; __host__ __device__ difference_type size() const { diff --git a/thrust/examples/include/timer.h b/thrust/examples/include/timer.h index 0ee906bc0ab..143fbed2502 100644 --- a/thrust/examples/include/timer.h +++ b/thrust/examples/include/timer.h @@ -77,7 +77,7 @@ struct timer restart(); } - ~timer() {} + ~timer() = default; void restart() { diff --git a/thrust/examples/uninitialized_vector.cu b/thrust/examples/uninitialized_vector.cu index a76cbb3228f..743d17014af 100644 --- a/thrust/examples/uninitialized_vector.cu +++ b/thrust/examples/uninitialized_vector.cu @@ -21,11 +21,11 @@ struct uninitialized_allocator : thrust::device_allocator // marked __host__ __device__, but the current Thrust device_allocator // can only be constructed and destroyed on the host; therefore, we // define these as host only - __host__ uninitialized_allocator() {} + __host__ uninitialized_allocator() {} // NOLINT(modernize-use-equals-default) __host__ uninitialized_allocator(const uninitialized_allocator& other) : thrust::device_allocator(other) {} - __host__ ~uninitialized_allocator() {} + __host__ ~uninitialized_allocator() {} // NOLINT(modernize-use-equals-default) uninitialized_allocator& operator=(const uninitialized_allocator&) = default; diff --git a/thrust/testing/allocator.cu b/thrust/testing/allocator.cu index ef2aff4e0fe..c845333c366 100644 --- a/thrust/testing/allocator.cu +++ b/thrust/testing/allocator.cu @@ -22,7 +22,7 @@ template struct my_allocator_with_custom_construct1 : thrust::device_malloc_allocator { - _CCCL_HOST_DEVICE my_allocator_with_custom_construct1() {} + my_allocator_with_custom_construct1() = default; _CCCL_HOST_DEVICE void construct(T* p) { @@ -43,7 +43,7 @@ DECLARE_VARIABLE_UNITTEST(TestAllocatorCustomDefaultConstruct); template struct my_allocator_with_custom_construct2 : thrust::device_malloc_allocator { - _CCCL_HOST_DEVICE my_allocator_with_custom_construct2() {} + my_allocator_with_custom_construct2() = default; template _CCCL_HOST_DEVICE void construct(T* p, const Arg&) @@ -80,13 +80,13 @@ struct my_allocator_with_custom_destroy static bool g_state; - _CCCL_HOST my_allocator_with_custom_destroy() {} + _CCCL_HOST my_allocator_with_custom_destroy() {} // NOLINT(modernize-use-equals-default) _CCCL_HOST my_allocator_with_custom_destroy(const my_allocator_with_custom_destroy& other) : use_me_to_alloc(other.use_me_to_alloc) {} - _CCCL_HOST ~my_allocator_with_custom_destroy() {} + _CCCL_HOST ~my_allocator_with_custom_destroy() {} // NOLINT(modernize-use-equals-default) _CCCL_HOST_DEVICE void destroy(T*) noexcept { @@ -149,13 +149,13 @@ struct my_minimal_allocator using reference = T&; using const_reference = const T&; - _CCCL_HOST my_minimal_allocator() {} + _CCCL_HOST my_minimal_allocator() {} // NOLINT(modernize-use-equals-default) _CCCL_HOST my_minimal_allocator(const my_minimal_allocator& other) : use_me_to_alloc(other.use_me_to_alloc) {} - _CCCL_HOST ~my_minimal_allocator() {} + _CCCL_HOST ~my_minimal_allocator() {} // NOLINT(modernize-use-equals-default) value_type* allocate(std::ptrdiff_t n) { diff --git a/thrust/testing/cuda/generate.cu b/thrust/testing/cuda/generate.cu index 02491a8a3d0..67fe060a82b 100644 --- a/thrust/testing/cuda/generate.cu +++ b/thrust/testing/cuda/generate.cu @@ -8,7 +8,7 @@ struct return_value { T val; - return_value() {} + return_value() = default; return_value(T v) : val(v) {} diff --git a/thrust/testing/generate.cu b/thrust/testing/generate.cu index b5023275f97..ce0e6113ed0 100644 --- a/thrust/testing/generate.cu +++ b/thrust/testing/generate.cu @@ -12,7 +12,7 @@ struct return_value { T val; - return_value() {} + return_value() = default; return_value(T v) : val(v) {} diff --git a/thrust/testing/mr_pool.cu b/thrust/testing/mr_pool.cu index 29423cb3e91..1ffbc22473d 100644 --- a/thrust/testing/mr_pool.cu +++ b/thrust/testing/mr_pool.cu @@ -42,7 +42,7 @@ struct tracked_pointer : ptr(ptr) {} - _CCCL_HOST_DEVICE ~tracked_pointer() {} + ~tracked_pointer() = default; template operator tracked_pointer() const diff --git a/thrust/testing/out_of_memory_recovery.cu b/thrust/testing/out_of_memory_recovery.cu index d1df2960d29..e94cb4d0493 100644 --- a/thrust/testing/out_of_memory_recovery.cu +++ b/thrust/testing/out_of_memory_recovery.cu @@ -18,8 +18,8 @@ struct non_trivial { - _CCCL_HOST_DEVICE non_trivial() {} - _CCCL_HOST_DEVICE ~non_trivial() {} + _CCCL_HOST_DEVICE non_trivial() {} // NOLINT(modernize-use-equals-default) + _CCCL_HOST_DEVICE ~non_trivial() {} // NOLINT(modernize-use-equals-default) }; void test_out_of_memory_recovery() diff --git a/thrust/testing/swap_ranges.cu b/thrust/testing/swap_ranges.cu index a7ab8333cc4..a0bcf279183 100644 --- a/thrust/testing/swap_ranges.cu +++ b/thrust/testing/swap_ranges.cu @@ -115,10 +115,7 @@ struct type_with_swap , m_swapped(s) {} - inline _CCCL_HOST_DEVICE type_with_swap(const type_with_swap& other) - : m_x(other.m_x) - , m_swapped(other.m_swapped) - {} + inline type_with_swap(const type_with_swap& other) = default; inline _CCCL_HOST_DEVICE bool operator==(const type_with_swap& other) const { diff --git a/thrust/testing/type_traits.cu b/thrust/testing/type_traits.cu index b863b487da5..94285b52b7b 100644 --- a/thrust/testing/type_traits.cu +++ b/thrust/testing/type_traits.cu @@ -51,7 +51,7 @@ DECLARE_UNITTEST(TestIsContiguousIterator); struct NonTriviallyCopyable { - NonTriviallyCopyable(const NonTriviallyCopyable&) {} + NonTriviallyCopyable(const NonTriviallyCopyable&) {} // NOLINT(modernize-use-equals-default) }; THRUST_PROCLAIM_TRIVIALLY_RELOCATABLE(NonTriviallyCopyable); diff --git a/thrust/testing/uninitialized_copy.cu b/thrust/testing/uninitialized_copy.cu index 72545356e92..5d2bfcc8438 100644 --- a/thrust/testing/uninitialized_copy.cu +++ b/thrust/testing/uninitialized_copy.cu @@ -114,12 +114,7 @@ struct CopyConstructTest (copy_constructed_on_device = false; copy_constructed_on_host = true;)); } - _CCCL_HOST_DEVICE CopyConstructTest& operator=(const CopyConstructTest& x) - { - copy_constructed_on_host = x.copy_constructed_on_host; - copy_constructed_on_device = x.copy_constructed_on_device; - return *this; - } + CopyConstructTest& operator=(const CopyConstructTest&) = default; bool copy_constructed_on_host{false}; bool copy_constructed_on_device{false}; diff --git a/thrust/testing/uninitialized_fill.cu b/thrust/testing/uninitialized_fill.cu index b6e0a14c248..77d1dc31f8b 100644 --- a/thrust/testing/uninitialized_fill.cu +++ b/thrust/testing/uninitialized_fill.cu @@ -123,12 +123,7 @@ struct CopyConstructTest (copy_constructed_on_device = false; copy_constructed_on_host = true;)); } - _CCCL_HOST_DEVICE CopyConstructTest& operator=(const CopyConstructTest& x) - { - copy_constructed_on_host = x.copy_constructed_on_host; - copy_constructed_on_device = x.copy_constructed_on_device; - return *this; - } + CopyConstructTest& operator=(const CopyConstructTest&) = default; bool copy_constructed_on_host{false}; bool copy_constructed_on_device{false}; diff --git a/thrust/testing/unittest/exceptions.h b/thrust/testing/unittest/exceptions.h index 90458daf62f..7ccb41995b0 100644 --- a/thrust/testing/unittest/exceptions.h +++ b/thrust/testing/unittest/exceptions.h @@ -12,7 +12,7 @@ class UnitTestException public: std::string message; - UnitTestException() {} + UnitTestException() = default; UnitTestException(std::string msg) : message(std::move(msg)) {} @@ -35,7 +35,7 @@ class UnitTestException class UnitTestError : public UnitTestException { public: - UnitTestError() {} + UnitTestError() = default; UnitTestError(const std::string& msg) : UnitTestException(msg) {} @@ -44,7 +44,7 @@ class UnitTestError : public UnitTestException class UnitTestFailure : public UnitTestException { public: - UnitTestFailure() {} + UnitTestFailure() = default; UnitTestFailure(const std::string& msg) : UnitTestException(msg) {} @@ -53,7 +53,7 @@ class UnitTestFailure : public UnitTestException class UnitTestKnownFailure : public UnitTestException { public: - UnitTestKnownFailure() {} + UnitTestKnownFailure() = default; UnitTestKnownFailure(const std::string& msg) : UnitTestException(msg) {} diff --git a/thrust/testing/unittest/testframework.h b/thrust/testing/unittest/testframework.h index 8e6278216aa..c4f39b57a26 100644 --- a/thrust/testing/unittest/testframework.h +++ b/thrust/testing/unittest/testframework.h @@ -330,9 +330,9 @@ class UnitTest { public: std::string name; - UnitTest() {} + UnitTest() = default; UnitTest(const char* name); - virtual ~UnitTest() {} + virtual ~UnitTest() = default; virtual void run() {} bool operator<(const UnitTest& u) const @@ -359,7 +359,7 @@ class UnitTestDriver virtual bool post_test_smoke_check(const UnitTest& test, bool concise); public: - inline virtual ~UnitTestDriver() {} + inline virtual ~UnitTestDriver() = default; void register_test(UnitTest* test); virtual bool run_tests(const ArgumentSet& args, const ArgumentMap& kwargs); diff --git a/thrust/testing/vector_allocators.cu b/thrust/testing/vector_allocators.cu index e877824784d..59054dc2725 100644 --- a/thrust/testing/vector_allocators.cu +++ b/thrust/testing/vector_allocators.cu @@ -15,7 +15,7 @@ public: : state(i) {} - ~stateful_allocator() {} + _CCCL_HOST ~stateful_allocator() {} // NOLINT(modernize-use-equals-default) stateful_allocator(const stateful_allocator& other) : BaseAlloc(other) diff --git a/thrust/thrust/device_allocator.h b/thrust/thrust/device_allocator.h index 89f2c1a4b3b..2e2cc310167 100644 --- a/thrust/thrust/device_allocator.h +++ b/thrust/thrust/device_allocator.h @@ -120,7 +120,7 @@ class device_allocator }; /*! Default constructor has no effect. */ - _CCCL_HOST_DEVICE device_allocator() {} + device_allocator() = default; /*! Copy constructor has no effect. */ _CCCL_HOST_DEVICE device_allocator(const device_allocator& other) @@ -136,7 +136,7 @@ class device_allocator device_allocator& operator=(const device_allocator&) = default; /*! Destructor has no effect. */ - _CCCL_HOST_DEVICE ~device_allocator() {} + ~device_allocator() = default; }; /*! \} // allocators diff --git a/thrust/thrust/device_malloc_allocator.h b/thrust/thrust/device_malloc_allocator.h index 0e3d5cbfe86..238f08553f4 100644 --- a/thrust/thrust/device_malloc_allocator.h +++ b/thrust/thrust/device_malloc_allocator.h @@ -103,13 +103,13 @@ class device_malloc_allocator }; // end rebind /*! No-argument constructor has no effect. */ - _CCCL_HOST_DEVICE inline device_malloc_allocator() {} + inline device_malloc_allocator() = default; /*! No-argument destructor has no effect. */ - _CCCL_HOST_DEVICE inline ~device_malloc_allocator() {} + inline ~device_malloc_allocator() = default; /*! Copy constructor has no effect. */ - _CCCL_HOST_DEVICE inline device_malloc_allocator(device_malloc_allocator const&) {} + inline device_malloc_allocator(device_malloc_allocator const&) = default; /*! Constructor from other \p device_malloc_allocator has no effect. */ template diff --git a/thrust/thrust/device_vector.h b/thrust/thrust/device_vector.h index 03af36a966b..d28ecad040b 100644 --- a/thrust/thrust/device_vector.h +++ b/thrust/thrust/device_vector.h @@ -76,9 +76,8 @@ class device_vector : public detail::vector_base /*! The destructor erases the elements. */ - // Define an empty destructor to explicitly specify - // its execution space qualifier, as a workaround for nvcc warning - ~device_vector() {} + _CCCL_EXEC_CHECK_DISABLE + _CCCL_HOST ~device_vector() {} // NOLINT(modernize-use-equals-default) /*! This constructor creates a \p device_vector with the given * size. diff --git a/thrust/thrust/host_vector.h b/thrust/thrust/host_vector.h index db9de941db3..4e0da78b8a1 100644 --- a/thrust/thrust/host_vector.h +++ b/thrust/thrust/host_vector.h @@ -91,9 +91,8 @@ class host_vector : public detail::vector_base * .. versionadded:: 2.2.0 * \endverbatim */ - // Define an empty destructor to explicitly specify - // its execution space qualifier, as a workaround for nvcc warning - _CCCL_HOST ~host_vector() {} + _CCCL_EXEC_CHECK_DISABLE + _CCCL_HOST ~host_vector() {} // NOLINT(modernize-use-equals-default) /*! This constructor creates a \p host_vector with the given * size. diff --git a/thrust/thrust/mr/allocator.h b/thrust/thrust/mr/allocator.h index 04f6dad488d..8436c1e78b2 100644 --- a/thrust/thrust/mr/allocator.h +++ b/thrust/thrust/mr/allocator.h @@ -206,7 +206,7 @@ class stateless_resource_allocator : public thrust::mr::allocator stateless_resource_allocator& operator=(const stateless_resource_allocator&) = default; /*! Destructor. */ - _CCCL_HOST_DEVICE ~stateless_resource_allocator() {} + ~stateless_resource_allocator() = default; }; /*! \} // allocators diff --git a/thrust/thrust/mr/disjoint_pool.h b/thrust/thrust/mr/disjoint_pool.h index e1a6dac6fb6..84c3903e4d4 100644 --- a/thrust/thrust/mr/disjoint_pool.h +++ b/thrust/thrust/mr/disjoint_pool.h @@ -235,7 +235,11 @@ class disjoint_unsynchronized_pool_resource final _CCCL_EXEC_CHECK_DISABLE pool& operator=(const pool&) = default; - _CCCL_HOST ~pool() {} + // If we = default this (even with _CCCL_HOST annotation), then nvcc will synthesize a + // different subobject destruction code for the pool vector below. I am not entirely sure + // why, but it chooses to instantiate it as host-device instead of host, then complains we + // cannot call host-device destructors from host-only + _CCCL_HOST ~pool() {} // NOLINT(modernize-use-equals-default) pointer_vector free_blocks{}; std::size_t previous_allocated_count{}; diff --git a/thrust/thrust/system/cuda/detail/core/util.h b/thrust/thrust/system/cuda/detail/core/util.h index 6aa87de0fc0..96b035b04d6 100644 --- a/thrust/thrust/system/cuda/detail/core/util.h +++ b/thrust/thrust/system/cuda/detail/core/util.h @@ -227,13 +227,7 @@ struct AgentPlan , grid_size(grid_size_) {} - THRUST_RUNTIME_FUNCTION AgentPlan(AgentPlan const& plan) - : block_threads(plan.block_threads) - , items_per_thread(plan.items_per_thread) - , items_per_tile(plan.items_per_tile) - , shared_memory_size(plan.shared_memory_size) - , grid_size(plan.grid_size) - {} + AgentPlan(AgentPlan const& plan) = default; template THRUST_RUNTIME_FUNCTION diff --git a/thrust/thrust/system/cuda/detail/error.inl b/thrust/thrust/system/cuda/detail/error.inl index 73cc9a20d73..1b3c624adb2 100644 --- a/thrust/thrust/system/cuda/detail/error.inl +++ b/thrust/thrust/system/cuda/detail/error.inl @@ -34,7 +34,7 @@ namespace cuda_cub::detail class cuda_error_category : public error_category { public: - inline cuda_error_category() {} + inline cuda_error_category() = default; inline const char* name() const override { diff --git a/thrust/thrust/system/cuda/detail/reduce.h b/thrust/thrust/system/cuda/detail/reduce.h index b8d326e27ca..f98f9af258f 100644 --- a/thrust/thrust/system/cuda/detail/reduce.h +++ b/thrust/thrust/system/cuda/detail/reduce.h @@ -163,7 +163,7 @@ struct ReduceAgent { cub::GridMappingStrategy grid_mapping; - THRUST_RUNTIME_FUNCTION Plan() {} + Plan() = default; template THRUST_RUNTIME_FUNCTION Plan(P) diff --git a/thrust/thrust/system/detail/bad_alloc.h b/thrust/thrust/system/detail/bad_alloc.h index 17c3b3062dd..405ff832121 100644 --- a/thrust/thrust/system/detail/bad_alloc.h +++ b/thrust/thrust/system/detail/bad_alloc.h @@ -32,7 +32,7 @@ class bad_alloc : public std::bad_alloc m_what += w; } // end bad_alloc() - inline ~bad_alloc() noexcept override {} + inline ~bad_alloc() noexcept override = default; inline const char* what() const noexcept override { diff --git a/thrust/thrust/system/detail/error_category.inl b/thrust/thrust/system/detail/error_category.inl index 1afacc61ea9..609d45fbe8b 100644 --- a/thrust/thrust/system/detail/error_category.inl +++ b/thrust/thrust/system/detail/error_category.inl @@ -64,7 +64,7 @@ namespace detail class generic_error_category : public error_category { public: - inline generic_error_category() {} + inline generic_error_category() = default; inline const char* name() const override { @@ -88,7 +88,7 @@ public: class system_error_category : public error_category { public: - inline system_error_category() {} + inline system_error_category() = default; inline const char* name() const override { diff --git a/thrust/thrust/system/system_error.h b/thrust/thrust/system/system_error.h index 4bbbde601f7..cbd16a6c827 100644 --- a/thrust/thrust/system/system_error.h +++ b/thrust/thrust/system/system_error.h @@ -134,7 +134,7 @@ class system_error : public std::runtime_error /*! Destructor does not throw. */ - inline ~system_error() noexcept override {} + inline ~system_error() noexcept override = default; /*! Returns an object encoding the error. * \return ec or error_code(ev, ecat), from the