Commit e840c2d4 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Fix some violations of -Werror=class-memaccess under gcc8

Summary: Pull Request resolved: https://github.com/facebook/folly/pull/981

Reviewed By: Orvid

Differential Revision: D13374621

Pulled By: yfeldblum

fbshipit-source-id: 00665529250cd03d9ca02f72f36efe505c280aa3
parent 1d2247b4
...@@ -463,7 +463,7 @@ struct AtomicUnorderedInsertMap { ...@@ -463,7 +463,7 @@ struct AtomicUnorderedInsertMap {
void zeroFillSlots() { void zeroFillSlots() {
using folly::detail::GivesZeroFilledMemory; using folly::detail::GivesZeroFilledMemory;
if (!GivesZeroFilledMemory<Allocator>::value) { if (!GivesZeroFilledMemory<Allocator>::value) {
memset(slots_, 0, mmapRequested_); memset(static_cast<void*>(slots_), 0, mmapRequested_);
} }
} }
}; };
......
...@@ -450,7 +450,7 @@ class fbvector { ...@@ -450,7 +450,7 @@ class fbvector {
static void S_uninitialized_fill_n(T* dest, size_type n) { static void S_uninitialized_fill_n(T* dest, size_type n) {
if (folly::IsZeroInitializable<T>::value) { if (folly::IsZeroInitializable<T>::value) {
if (LIKELY(n != 0)) { if (LIKELY(n != 0)) {
std::memset(dest, 0, sizeof(T) * n); std::memset((void*)dest, 0, sizeof(T) * n);
} }
} else { } else {
auto b = dest; auto b = dest;
...@@ -1245,7 +1245,8 @@ class fbvector { ...@@ -1245,7 +1245,8 @@ class fbvector {
if (last - first >= cend() - last) { if (last - first >= cend() - last) {
std::memcpy((void*)first, (void*)last, (cend() - last) * sizeof(T)); std::memcpy((void*)first, (void*)last, (cend() - last) * sizeof(T));
} else { } else {
std::memmove((iterator)first, last, (cend() - last) * sizeof(T)); std::memmove(
(void*)first, (void*)last, (cend() - last) * sizeof(T));
} }
impl_.e_ -= (last - first); impl_.e_ -= (last - first);
} else { } else {
...@@ -1340,7 +1341,7 @@ class fbvector { ...@@ -1340,7 +1341,7 @@ class fbvector {
impl_.e_ += n; impl_.e_ += n;
} else { } else {
if (folly::IsRelocatable<T>::value && usingStdAllocator::value) { if (folly::IsRelocatable<T>::value && usingStdAllocator::value) {
std::memmove(position + n, position, tail * sizeof(T)); std::memmove((void*)(position + n), (void*)position, tail * sizeof(T));
impl_.e_ += n; impl_.e_ += n;
} else { } else {
D_uninitialized_move_a(impl_.e_, impl_.e_ - n, impl_.e_); D_uninitialized_move_a(impl_.e_, impl_.e_ - n, impl_.e_);
......
...@@ -1484,7 +1484,10 @@ struct SingleElementQueue { ...@@ -1484,7 +1484,10 @@ struct SingleElementQueue {
T&& goner, T&& goner,
ImplByRelocation) noexcept { ImplByRelocation) noexcept {
sequencer_.waitForTurn(turn * 2, spinCutoff, updateSpinCutoff); sequencer_.waitForTurn(turn * 2, spinCutoff, updateSpinCutoff);
memcpy(&contents_, &goner, sizeof(T)); memcpy(
static_cast<void*>(&contents_),
static_cast<void const*>(&goner),
sizeof(T));
sequencer_.completeTurn(turn * 2); sequencer_.completeTurn(turn * 2);
new (&goner) T(); new (&goner) T();
} }
...@@ -1503,7 +1506,10 @@ struct SingleElementQueue { ...@@ -1503,7 +1506,10 @@ struct SingleElementQueue {
// unlikely, but if we don't complete our turn the queue will die // unlikely, but if we don't complete our turn the queue will die
} }
sequencer_.waitForTurn(turn * 2 + 1, spinCutoff, updateSpinCutoff); sequencer_.waitForTurn(turn * 2 + 1, spinCutoff, updateSpinCutoff);
memcpy(&elem, &contents_, sizeof(T)); memcpy(
static_cast<void*>(&elem),
static_cast<void const*>(&contents_),
sizeof(T));
sequencer_.completeTurn(turn * 2 + 1); sequencer_.completeTurn(turn * 2 + 1);
} }
......
...@@ -250,7 +250,10 @@ struct IntegralSizePolicy<SizeType, true> ...@@ -250,7 +250,10 @@ struct IntegralSizePolicy<SizeType, true>
template <class T> template <class T>
typename std::enable_if<folly::is_trivially_copyable<T>::value>::type typename std::enable_if<folly::is_trivially_copyable<T>::value>::type
moveToUninitialized(T* first, T* last, T* out) { moveToUninitialized(T* first, T* last, T* out) {
std::memmove(out, first, (last - first) * sizeof *first); std::memmove(
static_cast<void*>(out),
static_cast<void const*>(first),
(last - first) * sizeof *first);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment