q_uninitialized_relocate: use memcpy, not memmove
The [first, first+n) and [out, out+n) ranges cannot possibly overlap, as by definition the former contains live objects while the latter points into uninitialized storage. So we can use memcpy here, and not memmove. Change-Id: I4a1b39f73ffa67915c5252938554f45f4444293e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
eb4641210c
commit
4dbd97c8f9
@ -72,10 +72,10 @@ template <typename T, typename N>
|
||||
void q_uninitialized_relocate_n(T* first, N n, T* out)
|
||||
{
|
||||
if constexpr (QTypeInfo<T>::isRelocatable) {
|
||||
if (n != N(0)) { // even if N == 0, out == nullptr or first == nullptr are UB for memmove()
|
||||
std::memmove(static_cast<void*>(out),
|
||||
static_cast<const void*>(first),
|
||||
n * sizeof(T));
|
||||
if (n != N(0)) { // even if N == 0, out == nullptr or first == nullptr are UB for memcpy()
|
||||
std::memcpy(static_cast<void *>(out),
|
||||
static_cast<const void *>(first),
|
||||
n * sizeof(T));
|
||||
}
|
||||
} else {
|
||||
q_uninitialized_move_if_noexcept_n(first, n, out);
|
||||
|
Loading…
Reference in New Issue
Block a user