From 19294362e843bc18e4475558ade8d01e1fd3daf0 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sat, 7 Dec 2024 17:31:04 -0500 Subject: [PATCH] AlignedVector: only use memset() with default-constructible types. This is slightly less restrictive than the present version. --- include/deal.II/base/aligned_vector.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/include/deal.II/base/aligned_vector.h b/include/deal.II/base/aligned_vector.h index b976df0829..4ee1522094 100644 --- a/include/deal.II/base/aligned_vector.h +++ b/include/deal.II/base/aligned_vector.h @@ -944,10 +944,10 @@ namespace internal return; Assert(destination != nullptr, ExcInternalError()); - // do not use memcmp for long double because on some systems it does not - // completely fill its memory and may lead to false positives in - // e.g. valgrind - if constexpr (std::is_trivial_v == true && + // do not use memcmp() for long double because on some systems it does not + // completely fill its memory and may lead to false positives in e.g. + // valgrind + if constexpr (std::is_trivially_default_constructible_v == true && std::is_same_v == false) { const unsigned char zero[sizeof(T)] = {}; @@ -967,8 +967,9 @@ namespace internal apply_to_subrange(const std::size_t begin, const std::size_t end) const override { - // Classes with trivial assignment of zero can use memset. - if constexpr (std::is_trivial_v == true) + // Only use memset() with types whose default constructors don't do + // anything. + if constexpr (std::is_trivially_default_constructible_v == true) if (trivial_element) { std::memset(destination_ + begin, 0, (end - begin) * sizeof(T)); @@ -1052,8 +1053,9 @@ namespace internal apply_to_subrange(const std::size_t begin, const std::size_t end) const override { - // Classes with trivial assignment of zero can use memset. - if constexpr (std::is_trivial_v == true) + // Only use memset() with types whose default constructors don't do + // anything. + if constexpr (std::is_trivially_default_constructible_v == true) std::memset(destination_ + begin, 0, (end - begin) * sizeof(T)); else default_construct_or_assign(begin, -- 2.39.5