Skip to content

Commit c00369f

Browse files
[libc++] Silent warning related to memcpy of non trivially-copyable data
1 parent 24a0e9c commit c00369f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

libcxx/include/__memory/uninitialized_algorithms.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ __uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _
638638
__guard.__complete();
639639
std::__allocator_destroy(__alloc, __first, __last);
640640
} else {
641-
__builtin_memcpy(__result, __first, sizeof(_Tp) * (__last - __first));
641+
__builtin_memcpy((void*)__result, __first, sizeof(_Tp) * (__last - __first));
642642
}
643643
}
644644

libcxx/test/std/utilities/expected/types.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ template <int Constant>
162162
struct TailClobberer {
163163
constexpr TailClobberer() noexcept {
164164
if (!std::is_constant_evaluated()) {
165-
std::memset(this, Constant, sizeof(*this));
165+
std::memset((void*)this, Constant, sizeof(*this));
166166
}
167167
// Always set `b` itself to `false` so that the comparison works.
168168
b = false;
@@ -245,7 +245,7 @@ struct BoolWithPadding {
245245
constexpr explicit BoolWithPadding() noexcept : BoolWithPadding(false) {}
246246
constexpr BoolWithPadding(bool val) noexcept {
247247
if (!std::is_constant_evaluated()) {
248-
std::memset(this, 0, sizeof(*this));
248+
std::memset((void*)this, 0, sizeof(*this));
249249
}
250250
val_ = val;
251251
}
@@ -268,7 +268,7 @@ struct IntWithoutPadding {
268268
constexpr explicit IntWithoutPadding() noexcept : IntWithoutPadding(0) {}
269269
constexpr IntWithoutPadding(int val) noexcept {
270270
if (!std::is_constant_evaluated()) {
271-
std::memset(this, 0, sizeof(*this));
271+
std::memset((void*)this, 0, sizeof(*this));
272272
}
273273
val_ = val;
274274
}

libcxx/test/support/min_allocator.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -465,14 +465,14 @@ class safe_allocator {
465465
TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) {
466466
T* memory = std::allocator<T>().allocate(n);
467467
if (!TEST_IS_CONSTANT_EVALUATED)
468-
std::memset(memory, 0, sizeof(T) * n);
468+
std::memset((void*)memory, 0, sizeof(T) * n);
469469

470470
return memory;
471471
}
472472

473473
TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) {
474474
if (!TEST_IS_CONSTANT_EVALUATED)
475-
DoNotOptimize(std::memset(p, 0, sizeof(T) * n));
475+
DoNotOptimize(std::memset((void*)p, 0, sizeof(T) * n));
476476
std::allocator<T>().deallocate(p, n);
477477
}
478478

0 commit comments

Comments
 (0)